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.