How to convert DataFrame column type from string to datetime with Python Pandas?

To convert DataFrame column type from string to datetime with Python Pandas, we can use the to_datetime method.

For instance, we write

df['col'] = pd.to_datetime(df['col'])

to call to_datetime with df['col'] to covert the values in the col column to datetimes and assign them back to the col column.