【发布时间】:2018-11-07 05:18:16
【问题描述】:
我有一个column,不同的活动由,分隔
Activities
Bathing the puppy, cooking for family
cooking for family, cooking for family
morning walk, cooking for family, Bathing the puppy
Bathing the puppy, Bathing the puppy,Bathing the puppy
如何创建一个单独的column,其中包含每行不同活动的计数。
我希望输出如下:
Activities Unique Activities
Bathing the puppy, cooking for family 2
cooking for family, cooking for family 1
morning walk, cooking for family, Bathing the puppy 3
Bathing the puppy, Bathing the puppy,Bathing the puppy 1
我在pandas 中尝试了nunique 方法,但这适用于整个列,而不是在每一行中给我不同的值。
【问题讨论】:
标签: python-2.7 pandas row