What's the equivalent of cut/qcut for pandas date fields?

后端 未结 4 1746
Happy的楠姐
Happy的楠姐 2020-12-31 20:13

Update: starting with version 0.20.0, pandas cut/qcut DOES handle date fields. See What\'s New for more.

pd.cut and pd.qcut now sup

4条回答
  •  有刺的猬
    2020-12-31 20:43

    How about using Series and putting the parts of the DataFrame that you're interested into that, then calling cut on the series object?

    price_series = pd.Series(df.price.tolist(), index=df.recd)
    

    and then

     pd.qcut(price_series, q=3)
    

    and so on. (Though I think @Jeff's answer is best)

提交回复
热议问题