python pandas dataframe 操作记录
从数据看select出数据后如何转换为dataframe
df = DataFrame(cur.fetchall())
如何更改列名,选取列,进行groupby操作
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进行遍历
for index, row in df.iterrows(): print row['c1'], row['c2']