Why do i get '1900-01-01' in my time column in pandas

Viewed 5503

I am working on a Data Frame in pandas. I wanted to convert my time column into to_datetime, I am getting 1900-01-01 before my time.

Some sample data,

  Date              hour
01-06-2013      23:00:00
02-06-2013      01:00:00
02-06-2013      21:00:00
02-06-2013      22:00:00
02-06-2013      23:00:00
03-06-2013      01:00:00
03-06-2013      21:00:00
03-06-2013      22:00:00
03-06-2013      23:00:00
04-06-2013      01:00:00

This what I tried,

df['hour'] = pd.to_datetime(df['hour'],format ='%H:%M:%S', errors = 'coerce')

I am getting like this,

print(df['hour'])

0        1900-01-01 23:00:00
1        1900-01-01 01:00:00
2        1900-01-01 21:00:00
3        1900-01-01 00:00:00

I do not need 1900-01-01 in my df. Why is this happening and how can I get rid of this?

1 Answers
Related