ValueError: Grouper and axis must be same length

后端 未结 1 515
北海茫月
北海茫月 2021-01-19 10:28

I have a dataframe with 38 columns, one of them is Time. I established a bin frame space

timeframe=[\'4-6\',\'7-9\',\'10-12\',\'13-15\',\'16-18\',\'19-21\',\         


        
相关标签:
1条回答
  • 2021-01-19 10:49

    I believe need create new column:

    df['bins'] = pd.cut(df['time'],bins,retbins=True, labels=timeframe)
    groups=df.groupby('bins')
    

    But is possible you get some NaNs in new column, because values outside of range 4-24, so groupby silently remove these rows.

    0 讨论(0)
提交回复
热议问题