w3resource

Pandas Series: dt.month_name() function

Series.dt.month_name() function

The dt.month_name() function is used to get the month names of the DateTimeIndex with specified locale.

Syntax:

Series.dt.month_name(self, *args, **kwargs)
Pandas Series: dt.month_name() function

Parameter:

Name Description Type / Default Value
locale Locale determining the language in which to return the month name. Default is English locale. str

Returns: Index
Index of month names.

Example:

Python-Pandas Code:

import numpy as np
import pandas as pd
idx = pd.date_range(start='2019-01', freq='M', periods=4)
idx

Output:

DatetimeIndex(['2019-01-31', '2019-02-28', '2019-03-31', '2019-04-30'], dtype='datetime64[ns]', freq='M')

Python-Pandas Code:

import numpy as np
import pandas as pd
idx = pd.date_range(start='2019-01', freq='M', periods=4)
idx.month_name()

Output:

Index(['January', 'February', 'March', 'April'], dtype='object')

Previous: Series.dt.ceil() function
Next: Series.dt.day_name() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/series/series-dt-month_name.php