I am struggling to convert an object type to datetime. It's a column from a dataframe that has values in format dd.mm.yyyy (e.g. 13.03.2021).
dataframe: df
column: time
values in format: dd.mm.yyyy
desired output: dd-mm-yyyy
Below are the options which I already tried, but it does not work out.
df['time'] = pd.to_timedelta(df['time'].astype(str))
df['time'] = datetime.strptime(df['time'], '%d-%m-%Y').date()
df['time'] = pd.to_datetime(df['time'], format='%d-%m-%Y')
df['time'] = pd.to_datetime(df['time'], dayfirst=True)
Any ideas? Thank you so much in advance.
df['time'] = pd.to_datetime(df['time'], infer_datetime_format=True)?pd.to_datetime(df['time'], format='%d.%m.%Y')