I have a df with the following structure:
my_df
date        hour  product
2019-06-06  17    laptopt
2019-06-06  15    printer
2019-06-07  14    laptopt
2019-06-07  17    desktop
How can I get a df like this:
hour  laptop  printer  desktop
14    1       0        0
15    0       1        0
16    0       0        0 
17    1       0        1
So far I've been trying doing my_df.groupby(["product","hour"]).count().unstack(level=0)
        date
product desktop laptop  printer
hour            
14      NaN     1.0     NaN
15      NaN     NaN     1.0
17      1.0     1.0     NaN
and I'm stucked there.
Thanks.
 
     
     
    