0

I have a dataframe of sales :

 ID| date   | sales
 1 |02-02-03| retail
 1 |02-02-03| retail
 2 |02-03-15| retail

I want to transform it into a time series so that each column is a date and the index is ID. I want the count of transactions for that id for that date. The dataframe should look like

 ID|02-02-03|02-03-15
 1 |   2    | 0
 2 |   0    | 1

I tried pivoting but it is not giving me the correct results

pd.pivot_table(df,  index=['ID'], columns=['date'], aggfunc={'date': np.sum,})
Py.rookie89
  • 119
  • 3
  • 15

0 Answers0