Pandas日期时间列(Python)中仅提取月份和年份

年份和月份合并的一种方法是对它们进行整数编码,如2014年8月的201408。

df['YearMonth'] = df['ArrivalDate'].map(lambda x: 1000*x.year + x.month)

猜你喜欢

转载自blog.csdn.net/dta0502/article/details/85041095