Extract day and month from a datetime object

后端 未结 4 1543
臣服心动
臣服心动 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:17

    This should do it:

    df['day'] = df['Date'].apply(lambda r:r.day)
    df['month'] = df['Date'].apply(lambda r:r.month)
    

提交回复
热议问题