I have Python Pandas DataFrame like below:
col1
----
01.05.2019
02.11.2022
11.08.2001
And col1 is in "object" format.
I need to read this Data Frame from csv and in "read_csv" function modify:
- format of this column from "object" to "date"
- form of presenting values, because when I use only:
df= pd.read_csv("df.csv", delimiter=";", index_col=0, parse_dates=['col1'])
format of "col1" is "date" but the form is changed to for example: "2019-05-01"
My code is as below:
df= pd.read_csv("df.csv", delimiter=";", index_col=0, parse_dates=['col1'], date_parser=lambda x: pd.to_datetime(x, format='%d.%m.%Y'))
How can I modify my code based of my needs ?
- Currently in cas I have form of
- date like: 01.05.2019
- Nevertheless, it is "object"
- I would like to modify format od column from "object" to "date" and still have values in column "date" in format like: 01.05.2019
- Neveerthleess, when I use my code I finally have format of data like "datetime" but form is not good because like: 2019-05-01.