Seaborn时间序列图

时间:2018-08-24 02:28:19

标签: pandas time-series seaborn

我有一个Dataframe train_data_new,其中有一个pick_datetime列,我只是从中提取日期部分:

train_data_new['pickup_datetime'] = pd.to_datetime(train_data_new.pickup_datetime)
train_data_new['pickup_date'] = train_data_new['pickup_datetime'].dt.date
train_data_new.reset_index(inplace = True)

接下来,我创建了另一个数据框,该数据框按Pickup_date分组乘车: 我正在尝试使用tsplot可视化此信息:

vendor_date = pd.DataFrame(train_data_new.groupby(['vendor_id','pickup_date'])['id'].count())
vendor_date.reset_index(inplace = True)
vendor_date['unit'] = 1
sns.tsplot(data = vendor_date, time = "pickup_date", value = 'id', unit = 'vendor_id', condition = "vendor_id")

       vendor_id pickup_date    id  unit
0            1  2016-01-01  3048     1
1            1  2016-01-02  2887     1
2            1  2016-01-03  2895     1
3            1  2016-01-04  3164     1
4            1  2016-01-05  3304     1
5            1  2016-01-06  3412     1
6            1  2016-01-07  3607     1

但是我得到一个错误:TypeError:float()参数必须是字符串或数字,而不是'datetime.date'

我在这里做错了什么?请提出建议!谢谢

0 个答案:

没有答案