我有一个数据集,其中包含“日期”列,其值类似于“ 2014年7月31日”,“ 2018年9月23日” ... 我想将月份放在不同的列中,使用“ df.to_datetime(df.MONTH,format ='%b')。dt.month”将它们转换为整数,然后返回以按日期索引对其进行排序。
如何从单元格中仅选择前三个字母?
我有一个数据集,其中包含“日期”列,其值类似于“ 2014年7月31日”,“ 2018年9月23日” ... 我想将月份放在不同的列中,使用“ df.to_datetime(df.MONTH,format ='%b')。dt.month”将它们转换为整数,然后返回以按日期索引对其进行排序。
如何从单元格中仅选择前三个字母?
You can try
to_datetime
with the date format%b %d, %Y
:码:
For more detail on how to get the date format, refer the doc