Table Modifications
General Info
Useful Snippets

8.0.7 Change column data type to datetime

Example:

import pandas as pd

# Create an example dataframe
df = pd.DataFrame({'Letter': ['A', 'B', 'C'] ,
                   'date_time_string': [ '26-02-2021 1:35 PM', '15-01-2021 1:13 AM', '21-03-2021 1:15 PM']
                   })

# Convert column data type to Datetime, and specify the format used in the column your converting from
df['date_time_formated']  = pd.to_datetime(df['date_time_string'], format = '%d-%m-%Y %I:%M %p')


#####################################
#           Common Date Formats
#####################################
# Code  Description                            Example
# %Y     Full Year                                2021
# %m    Month with zero                     06
# %d     Day of the month with zero    02
# %I      Hour (12hr clock) with zero    02
# %p     AM  or PM                              AM
# %M    minute with zero                    05
# %S     second with zero                   09