Time Series pooling up

timeseries
python
jupyter_notebook

#1

I want to pool the data year wise.
By using the below code I am able to pool the data month or daywise, but unable to pool for year wise. As I want to see the trend year wise.

train[‘mm_pickup’]=train.pickup_datetime.dt.month.astype(np.int8)

plt.figure(figsize=(12,2))
month_wise=train.groupby(‘mm_pickup’).agg({‘id’:‘count’}).reset_index()
sns.barplot(x=‘mm_pickup’,y=‘id’,data=month_wise)
plt.xlabel(‘Month wise pick up’)
plt.ylabel(‘no of counts’)
plt.xticks(range(0,7),mm_names[:6])
plt.title(‘Monthly pick up’)
pass

I want the plot to be a line plot so the trend is cleaely visible.


#2

can you show the data ?


#3

convert ur data in to datetime64[ns] format by using
df[‘name’] = pd.to_datetime(df[‘Date column name’])
now save it as string using
month_year=df[‘Date column name’].apply(lambda x: x.strftime(’%B-%Y’))
now
yearwise=df[‘mnth_year’].value_counts()
print yearwise


#4

It’s already in the datetime format with no null entries.
dtype - datetime64[ns]

I am able to group data month day hour wise. Then why not year wise?
Even dt.year or dt.is_year_end not working.


#5

Found the mistake and coorected it.
Thanks


#6

very good keep it up