简体   繁体   中英

Python .month format is numeric(1) want MMM(Jan)

I am trying to create a column to retrieve only month stat from Trade Trade Dt column.

I want format MMM below to be a number.

map_cat['Trade Month'] = pd.DatetimeIndex(map_cat['Trade Trade Dt']).month

另外一个选项:

map_cat['Trade Month'] = pd.DatetimeIndex(map_cat['Trde Trade Dt']).month_name().str[:3]

strftime与 %b 一起使用

map_cat['Trade Month'] = pd.DatetimeIndex(map_cat['Trde Trade Dt']).strftime('%b')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM