- くだすれPython(超初心者用) その28©2ch.net
137 :デフォルトの名無しさん[sage]:2015/11/23(月) 20:56:02.16 ID:jjQh9zUI - import numpy as np
import pandas as pd ary = [ {'name':'ooshima', 'age':'5'}, {'name':'teshima', 'age':'2'}, {'name':'teshima', 'age':'3'}, {'name':'teshima', 'age':'1'}, {'name':'yamashita', 'age':'3'} ] df = pd.DataFrame(ary) tbl = pd.pivot_table(df, values='age', index=['name'], aggfunc=np.max) ary = [{'name':k, 'age':v} for k,v in tbl.items()] print(ary) ?
|