I have a data frame as shown below
df
cust_id         product
1               tv
1               phone
2               bat
2               ball
3               bat
4               ball
4               bat
4               tv
4               phone
5               tv
6               bat
7               bat
7               ball
7               tv
8               phone
8               tv
From the above I would like to prepare a data frame as shown below.
Expected output:
cust_id        0         1            2           3         
      1        tv        phone        NaN         NaN
      2        bat       ball         NaN         NaN
      3        bat       NaN          NaN         NaN
      4        ball      bat          tv          phone
      5        tv        NaN          NaN         NaN
      6        bat       NaN          NaN         NaN
      7        bat       ball         tv          NaN
      8        phone     tv           NaN         NaN
I tried below code but it created the list of items as one column
s = df.groupby(['cust_id'])['product'].apply(list)
