转载大佬的,记录一下
import datetime
# 需要先转为时间类型
comment['评论时间'] = pd.to_datetime(comment['评论时间'])
# 提取即可
comment['Year'] = comment['评论时间'].dt.year
comment['Month'] = comment['评论时间'].dt.month
转载大佬的,记录一下
import datetime
# 需要先转为时间类型
comment['评论时间'] = pd.to_datetime(comment['评论时间'])
# 提取即可
comment['Year'] = comment['评论时间'].dt.year
comment['Month'] = comment['评论时间'].dt.month