python - Group elements using 2 columns and then create a dataframe -


i have following pandas dataframe:

enter image description here

the table contains information products bought clients , respective quantities.

i want create matrix of client(rows) x product(columns) , fill quantities , input zeros when client did not buy product, following:

enter image description here

how can that?

thanks,

rodrigo.

df.set_index(['user','products']).unstack() 

Comments