1

I have a dataframe1 that looks like below

date   Name  Value
Jan 1  Jon    12
Jan 2  Jon    17
Jan 1  Adam   19
Jan 2  Adam   24

i want to rearrange it into

date   Jon  Adam
Jan 1  12    19
Jan 2  17    24

i tried pd.pivottable as follows

results = pd.pivot_table(dataframe1, values='Value', index=['date'], columns=['Name'], fill_value=0,aggfunc=np.sum,)

it is throwing some weird values in the output. What am i doing wrong here.

windowws
  • 373
  • 1
  • 8
  • 20

0 Answers0