pandas to_datetime

Tobias Krabel
8080 Labs
Published in
1 min readJan 16, 2020
Photo by Aron Visuals on Unsplash

df[“column”] = pd.to_datetime( df[“column”], format=“%Y-%m-%d”)

Here’s how you generally change a column’s dtype to datetime in pandas.

If you set infer_datetime_format to True, pandas will try to identify in which format your dates are written. If pandas cannot infer the datetime format correctly, you can specify the format of your date column.

Here is an example

Tired of googling pandas commands?

With bamboolib, you don’t need to think about the pandas syntax anymore. Convert a column to datetime within seconds and get the pandas code, so that you can focus on what you want to do instead of how you do it.

--

--

Tobias Krabel
8080 Labs

Co-creator of bamboolib.com. I am always looking for ways to create better tools for Python Data Scientists.