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\',\
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.
NaN
4-24
groupby