I want to categorize data by month column e.g. date Month 2009-05-01==>May
I want to check outcomes by monthly In this table I am excluding years and only want to keep months.
I want to categorize data by month column e.g. date Month 2009-05-01==>May
I want to check outcomes by monthly In this table I am excluding years and only want to keep months.
This is simple when using pd.Series.dt.month_name (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.dt.month_name.html):
import pandas as pd
df = pd.DataFrame({
'date': pd.date_range('2000-01-01', '2010-01-01', freq='1M')
})
df['month'] = df.date.dt.month_name()
df.head()
Output
date month
0 2000-01-31 January
1 2000-02-29 February
2 2000-03-31 March
3 2000-04-30 April
4 2000-05-31 May