ValueError: time data does not match the given format

df_time = pd.DataFrame({'DOB': {0: '12FEB20210017', 1: '18AUG20210019'}})

df_time['DOB'] = pd.to_datetime(df_time.DOB,format='%d%b%Y%H:%M:%S')

ValueError: time data ’12FEB20210017′ does not match format ‘%d%b%Y:%H:%M:%S’ (match)

I don’t understand the problem with the format

>Solution :

The format needed a slight change.

   import pandas as pd
   df_time = pd.DataFrame({'DOB': {0: '12FEB20210017', 1: '18AUG20210019'}})
   #df_time['DOB'] = df_time['DOB'].str.lower()
   df_time['DOB'] = pd.to_datetime(df_time.DOB,format='%d%b%Y%H%M')

Leave a Reply