-1

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.

  • 1
    Welcome to StackOverflow. To help you better, try to add some example data so we can see what you are trying to do. – Erfan Apr 13 '19 at 12:42
  • Possible duplicate of [Extracting just Month and Year from Pandas Datetime column](https://stackoverflow.com/questions/25146121/extracting-just-month-and-year-from-pandas-datetime-column) – ResidentSleeper Apr 13 '19 at 12:44

1 Answers1

0

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
mrzo
  • 2,002
  • 1
  • 14
  • 26