Pandas: dt.month_name doesn't return the name of the month

Created on 25 Sep 2018  路  4Comments  路  Source: pandas-dev/pandas

I'm trying to get the name of the month of the year based on my datatime variable created_data in my dataframe df_noise, and tried:

df_noise['month'] = df_noise.created_date.dt.month_name

and pandas returns the following in every row of the column

<bound method PandasDelegate._add_delegate_accessors.<locals>._create_delegator_method.<locals>.f of <pandas.core.indexes.accessors.DatetimeProperties object at 0x0000011D017F9630>>

If I use

df_noise['month'] = df_noise.created_date.dt.month

pandas will return the numerical values of the month.

Am I missing somthing? Is there a way to get the name of the month? The doc here doesn't have examples.

verison:
'0.23.4'

Usage Question

Most helpful comment

This is because month_name is a method that needs to be called, and not an attribute (I have to say this is a bit confusing, as many of the other "datetime" related properties are actually attributes and not a method):

df_noise.created_date.dt.month_name()

Always welcome to add an example to that docstring!

All 4 comments

This is because month_name is a method that needs to be called, and not an attribute (I have to say this is a bit confusing, as many of the other "datetime" related properties are actually attributes and not a method):

df_noise.created_date.dt.month_name()

Always welcome to add an example to that docstring!

In general, we prefer that you ask such usage questions rather on StackOverflow or on the pydata mailing list (I recommend StackOverflow, you will get a quicker answer there).

The issue tracker here is more meant for bugs or enhancement requests.

@jorisvandenbossche my bad and I googled it and no answer on StackOverflow came up. Thanks for your clarification.

This is because month_name is a method that needs to be called, and not an attribute (I have to say this is a bit confusing, as many of the other "datetime" related properties are actually attributes and not a method):

df_noise.created_date.dt.month_name()

Always welcome to add an example to that docstring!

Thanks!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BDannowitz picture BDannowitz  路  3Comments

amelio-vazquez-reina picture amelio-vazquez-reina  路  3Comments

Ashutosh-Srivastav picture Ashutosh-Srivastav  路  3Comments

ericdf picture ericdf  路  3Comments

nathanielatom picture nathanielatom  路  3Comments