I have a dataframe that looks like this:
time amount user
0 2020-06 1 A
1 2020-06 1 B
2 2020-04 1 C
3 2020-04 2 A
4 2020-02 1 C
I want to make something like that:
2020-02 2020-04 2020-06
A 0 2 1
B 0 0 1
C 1 1 0
I am using this code
df.groupby(['user','time'])['amount'].sum()
df.unstack().fillna(0).reset_index()
but I am getting wrong results. Is my code correct?