用pd.Series.nunique在pandas中实现分组计数功能
grouped = data.groupby(["col1", "col2"])
grouped.agg({"col3": "count", "col4": pd.Series.nunique})
用pd.Series.nunique在pandas中实现分组计数功能
grouped = data.groupby(["col1", "col2"])
grouped.agg({"col3": "count", "col4": pd.Series.nunique})