Have dd-mm-yy in "date" column
05-01-15
need yyyy-mm-dd
2015-01-05
Solved with
df['date'] = pd.to_datetime(df.date, format='%d-%m-%y', errors='coerce')
Has it another solution?
Have dd-mm-yy in "date" column
05-01-15
need yyyy-mm-dd
2015-01-05
Solved with
df['date'] = pd.to_datetime(df.date, format='%d-%m-%y', errors='coerce')
Has it another solution?
from datetime import datetime
now = datetime.now()
date_time = now.strftime("%Y-%m-%d")
print("date and time:",date_time)
Or have a closer look at strftime documentation.
df['date'] = pd.to_datetime(df['date'])
Will transform your custom format to pandas recognized datetime, which you will be able to use for calculations.