以o2o大赛的数据为例
df_new = df[['User_id','Merchant_id']]
df_new_1 = df_new.groupby(['User_id'])['Merchant_id'].nunique()
在同一个'User_id'下,'Merchant_id'有多少个
df_new_1 = df_new.groupby(['User_id'])['Merchant_id'].value_counts()
Name: Merchant_id, dtype: int64
df_new_1 = df_new.groupby(['User_id'])['Merchant_id'].unique()
返回具体的unique值
Series.
nunique
(
dropna=True
)
[source]