# 首先 使用to_datetime转化为 datetime64 格式
df['date_column'] = pd.to_datetime(df['date_column'])
# strftime转化
df['mnth_yr'] = df['date_column'].apply(lambda x: x.strftime('%Y-%m'))
如图
# 首先 使用to_datetime转化为 datetime64 格式
df['date_column'] = pd.to_datetime(df['date_column'])
# strftime转化
df['mnth_yr'] = df['date_column'].apply(lambda x: x.strftime('%Y-%m'))
如图