vishal sankar
vishal sankar

Reputation: 33

Convert time column (object type) to datetime format

I have a separate column with HH:MM: SS object type. I want to convert object type to DateTime format. Encountering the error below. enter image description here

Dataset time column ["ACCIDENT_TIME]: enter image description here

Upvotes: 0

Views: 371

Answers (2)

j suman
j suman

Reputation: 125

You can try the below one also:

import pandas as pd
df['col_name'] = pd.to_datetime(df['col_name'], errors='coerce')

Upvotes: 1

j suman
j suman

Reputation: 125

if you want to change dtype of column you can do in below way:

df['col_name'] = df['col_name'].astype('datetime64[ns]')

Upvotes: 0

Related Questions