從數據看select出數據後如何轉換爲dataframefetch
df = DataFrame(cur.fetchall())
如何更改列名,選取列,進行groupby操做spa
df.columns = ['member_id', 'poi', 'num'] df = df[['member_id','num']] grouped = df.groupby('member_id') df = grouped.aggregate(lambda x: sorted(list(x),reverse=True)) df = df.reset_index()
如何對dataframe進行遍歷code
for index, row in df.iterrows(): print row['c1'], row['c2']