How to group a Series by values in pandas?

后端 未结 5 1883
悲&欢浪女
悲&欢浪女 2021-02-01 00:31

I currently have a pandas Series with dtype Timestamp, and I want to group it by date (and have many rows with different times in each group).

5条回答
  •  礼貌的吻别
    2021-02-01 00:55

    Three methods:

    DataFrame: pd.groupby(['column']).size()

    Series: sel.groupby(sel).size()

    Series to DataFrame:

    pd.DataFrame( sel, columns=['column']).groupby(['column']).size()

提交回复
热议问题