Time Series pooling up

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.

1 Like

can you show the data ?

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

1 Like

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.

Found the mistake and coorected it.
Thanks

very good keep it up