我目前在python熊猫中有一个DataFrame:
df = pd.DataFrame([['001','Trial',2018-11-10],
['001','Formal',2018-11-18],
['002','Trial',2018-11-10],
['002','Formal',2018-11-17]],
columns = ['id','type','paid_time'])
每个ID仅具有“ Trial”和“ Formal”两种类型。看起来像下面的样式。
id type paid_time
001 Trial 2018-11-10
001 Formal 2018-11-17
002 Trial 2018-11-10
002 Formal 2018-11-16
003 Trial 2018-11-11
003 Formal 2018-11-15
如何汇总“类型”并在“ paid_time”中映射值?
我期望的是:
id Trial_time Formal_time
001 2018-11-10 2018-11-17
002 2018-11-10 2018-11-16
003 2018-11-11 2018-11-15