达令说
您可以使用groupby的size:In [11]: df.groupby(["Group", "Size"]).size()Out[11]:Group SizeModerate Medium 1 Small 1Short Small 2Tall Large 1dtype: int64In [12]: df.groupby(["Group", "Size"]).size().reset_index(name="Time")Out[12]: Group Size Time0 Moderate Medium 11 Moderate Small 12 Short Small 23 Tall Large 1