I am a Pandas newbie and I like it a lot. I am trying to create a pivot table and having trouble. This is a small image file explaining my problem:
I have tried the following line but it doesn't output the way I want.
df = df.pivot_table(index = 'Time', columns = 'Item', values = 'Value', aggfunc = list)
try this:
output = pd.pivot_table(df, values='Value', index=['Time', 'ID'],
columns=['Item'], aggfunc=np.sum, fill_value="")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.