📌  相关文章
📜  pandas 从日期中提取月份年份 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:33.955000             🧑  作者: Mango

代码示例3
#if the date format comes in datetime, we can also extract the day/month/year using the to_period function
#where 'D', 'M', 'Y' are inputs
df['month_year'] = pd.to_datetime(df['birth_date']).dt.to_period('M')
df.head()