pandas.DatetimeIndex.month_name#

DatetimeIndex.month_name(*args, **kwargs)[源代码]#

属性的月份名称。 SeriesDatetimeIndex 具有指定的区域设置。

参数
locale字符串,可选

确定返回月份名称所使用的语言的区域设置。默认为英语区域设置。

退货
系列或指数

月份名称的系列或索引。

示例

>>> s = pd.Series(pd.date_range(start='2018-01', freq='M', periods=3))
>>> s
0   2018-01-31
1   2018-02-28
2   2018-03-31
dtype: datetime64[ns]
>>> s.dt.month_name()
0     January
1    February
2       March
dtype: object
>>> idx = pd.date_range(start='2018-01', freq='M', periods=3)
>>> idx
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
              dtype='datetime64[ns]', freq='M')
>>> idx.month_name()
Index(['January', 'February', 'March'], dtype='object')