我正在尝试创建一个列,以便从 Trade Trade Dt
列中仅检索月份统计数据。
我希望下面的 MMM 格式为数字。
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]
关于Python .month 格式是 numeric(1) 想要 MMM(Jan),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60378587/