Home > database >  Python Converting column of object to dates
Python Converting column of object to dates

Time:04-15

enter image description here this continues , already cleaned the data removed missing vars, looked around and could not find a solution, thank you

datetime_str =fires.ALARM_DATE[1]
print(datetime_str)

outputs -> 2007-10-22 00:00:00

want to convert the column using

fires['CONT_DATE'] = pd.to_datetime(fires['CONT_DATE'], format ='%Y-%m-%d %H:%M:%S')

TypeError: Unrecognized value type: <class 'str'> enter image description here

CodePudding user response:

There is no mistake in your method of use. The real mistake is because of "pandas.tslib.OutOfBoundsDatetime: Out of bounds nanosecond timestamp:"

Timestamp Limitations

pandas.to_datetime

If 'coerce', then invalid parsing will be set as NaT.

pd.to_datetime(date_col_to_force, errors = 'coerce')
  • Related