Extract day and month from a datetime object

后端 未结 4 1518
臣服心动
臣服心动 2021-01-06 01:26

I have a column with dates in string format \'2017-01-01\'. Is there a way to extract day and month from it using pandas?

I have converted the column to

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-06 02:20

    A simple form:

    df['MM-DD'] = df['date'].dt.strftime('%m-%d')
    

提交回复
热议问题