Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

My timestamp looks like below in the dataframe of my column but it is in 'object'. I want to convert this into 'timestamp'. How can I convert all values such in my dataframe column into timestamp?

0    01/Jul/1995:00:00:01

1    01/Jul/1995:00:00:06

2    01/Jul/1995:00:00:09

3    01/Jul/1995:00:00:09

4    01/Jul/1995:00:00:09

Name: timestamp, dtype: object

I tried below code referring this stackoverflow post but it gives me error:

pd.to_datetime(df['timestamp'], format='%d/%b/%Y:%H:%M:%S.%f')

Below is the error:

ValueError: time data '01/Jul/1995:00:00:01' does not match format '%d/%b/%Y:%H:%M:%S.%f' (match)

1 Answer

0 votes
by (41.4k points)

To convert all values in dataframe column into timestamp, use the following format:

ourdates = pd.to_datetime(df['timestamp'], format='%d/%b/%Y:%H:%M:%S')

Browse Categories

...