1

I have a datetime column in my dataframe and I need to get the date out of it and put it in a separate column.

Format of values in dataframe:

column name: timeinutc 
value: 2019-03-20T20:00:29.6259945Z
Desired Output: 2019-03-20

So i tried this:

payers['eventtime']=pd.to_datetime(payers['timeinutc'],infer_datetime_format=True)

got result like this eventtime: 2019-03-20 20:00:29.625994500+00:00

Next thing I did:

payers['eventtime2'] = pd.to_datetime(payers['eventtime'].dt.tz_localize(None),infer_datetime_format=True)

it resulted in 2019-03-20 20:00:29.625994500

I only want the date out of my timeinutc column

Yuca
  • 5,558
  • 3
  • 21
  • 39
irum zahra
  • 387
  • 1
  • 6
  • 16

0 Answers0