I am trying to convert a column of dates in the format 4-Mar-20 into a integer or numeric value in order to fit as vector in machine learning model.
I keep getting error message:
ValueError: time data 'Date' does not match format '%d/%m/%Y' (match)
I am trying to convert a column of dates in the format 4-Mar-20 into a integer or numeric value in order to fit as vector in machine learning model.
I keep getting error message:
ValueError: time data 'Date' does not match format '%d/%m/%Y' (match)
 
    
     
    
    You should use the format like %d-%b-%y
from datetime import datetime
date1 = datetime.strptime('4-Mar-20', '%d-%b-%y')
print(date1) #2020-02-04 00:00:00
 
    
    Pandas library has inbuilt datetime convertor which does a very good job Here is a code snippet:
Import pandas as pd
pd.to_datetime("4-Mar-20")
This will convert without any issues
