从包含时间的数据框列创建列表

时间:2019-05-24 13:57:48

标签: python dataframe datetime pandas-groupby

我想创建多个列表,每个列表包含一个数据帧(orders_data)中的每小时数据,以及一列每日的ordersorders_data。['order_arrived']。

我首先确保orders_data ['order_arrived']为日期时间格式。

然后,我尝试使用内置函数pd.groupby()

orders_data['reached_time'] = pd.to_datetime(orders_data['order_arrived'],errors='coerce')

hourly_orders=orders_data['order_arrived'].groupby(pd.TimeGrouper(freq='60Min'))

我收到此错误:

TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Int64Index'

0 个答案:

没有答案
相关问题