I have a csv-file with several columns, one contains the date in the format dd.mm.yyyy
. Its entries (rows) aren't in chronological order. What I did to put them into order is transforming those values using pd.to_datetime
, followed by sort_values
. (Code below).
Desired output: 01.09.2019, 02.09.2019, 03.09.2019, ...., 30.03.2020
However, I get: 01.01.2020, 01.02.2020, 01.09.2019, 01.11.2019, ..., 31.12.2019
daten = pd.read_csv("gewichtstagebuch.csv", sep=";", decimal=",",
usecols=("Datum","Gewicht (kg)"))
pd.to_datetime(daten['Datum'])
daten.sort_values(by="Datum", ascending= True)
I tried other ways to sort or convert my data set but screenshot then Python assumes the months to be days and vise versa so that I still end up having the wrong result (e.g. forcing a format and strftime).