像这样的桌子
dates fruit
12-01-18 apple
12-01-18 orange
12-01-18 apple
12-02-18 banana
12-02-18 apple
12-02-18 orange
此处的代码:
import pandas as pd
pd.DataFrame({'date':['12-01-18']*3+['12-02-18']*3, 'fruit':['apple','orange','apple','banana','apple','orange']})
我想生成一个按日期分组的新表,但是列是每种水果的编号,如下所示
dates apple orange banana
12-01-18 2 1 0
12-02-18 1 1 1
谢谢。