四半期ごとのデータフレーム時間集計

方法1:

df_m.review_date.apply(lambda x: str(x.year)+' Q'+str(x.quarter))

ここに画像の説明を挿入
参照:見つかりません

方法2:

df_m.resample(rule= 'Q', on='review_date').agg({
    
    
    'open':'first',
    'high':'max',
})

df_m.resample(rule= 'Q', on='review_date').total_votes.agg(sum)

パラメータ:

  • ルール:Q四半期M月W週
  • on:時間データのどの列に集約されるかに基づく

おすすめ

転載: blog.csdn.net/Caiqiudan/article/details/111200930