Проблема заключается в преобразовании в даты и время, необходимо установить формат или dayfirst=True
, потому что DD/MM/YY
:
df1['Date'] = pd.to_datetime(df1['Date'], format='%d/%m/%y')
Или:
df1['Date'] = pd.to_datetime(df1['Date'], dayfirst=True)
И если необходимо построить график по названиям месяцевиспользуйте:
df1['Date'] = pd.to_datetime(df1['Date'], format='%d/%m/%y').dt.month_name()
#alternative
#df1['Date'] = pd.to_datetime(df1['Date'], format='%d/%m/%y').dt.strftime('%B')
df1.groupby('Date')['Value'].count().plot(kind = 'bar')

При необходимости правильного заказа месяцев:
months = ['January','February','March','April','May','June','July','August',
'September','October','November','December']
df1['Date'] = pd.Categorical(df1['Date'], categories=months, ordered=True)
df1.groupby('Date')['Value'].count().plot(kind = 'bar')

Если хотите отфильтровать 0
значения:
df1.groupby('Date')['Value'].count().pipe(lambda x: x[x != 0]).plot(kind = 'bar')

Спасибо @asongtoruin за другую идею:
df1['Date'] = pd.to_datetime(df1['Date'], format='%d/%m/%y')
#if necessary sorting datetimes
#df1 = df1.sort_values('Date')
df1['month_name'] = df1['Date'].dt.month_name()
df1.groupby('Date').agg({'Value': 'count', 'month_name': 'first'})
.plot(x='month_name', y='Value', kind='bar')