1

I have a csv file with a date column in format 'dd/mm/yyyy', e.g. (31/12/2019). When I read it into pandas dataframe, it gets turned into '2019-12-31'. I tried converting it back, but the format doesn't seem to change to what I want.

df= pd.read_csv('data.csv')
df['dates'] =pd.to_datetime(df["notification_date"], dayfirst=True)
df['dates'] = datetime.datetime(df['dates'], format = '%d/%m/%Y')
Programmer
  • 1,266
  • 5
  • 23
  • 44
  • This is pure representation. Your date object is stored as datetime and displayed by default like you see it.You can change the dateformat-representation. See dupe. – Patrick Artner Apr 11 '20 at 16:58
  • something like `df.style.format({"notification_date": lambda t: t.strftime("%d/%m/%Y")})` could work – Patrick Artner Apr 11 '20 at 17:00

0 Answers0