0

What I'm looking for is a dataframe that has a date column, but it does not have the data type datetime64ns, it currently has type object with the following format YYYY-mm-DD I need to change this format to d-m-Y

0     2019-05-14 
1     2019-05-14
2     2019-05-14
3     2019-05-14
4     2019-05-14

dataframe['fefuente'].apply(lambda x: f'{x:%d-%m-%Y}') I currently have this code, but I get the following error ValueError: Invalid format specifier

what he sought to obtain is something like this

0     14-05-2019
1     14-05-2019
2     14-05-2019
3     14-05-2019
4     14-05-2019

1 Answers1

2

You first need to convert the column to a datetime object.

dataframe['fefuente'] = pd.to_datetime(dataframe['fefuente'])

Then, as WeNYoBen said, you format the datetime.

dataframe['new_date']= dataframe['fefuente'].dt.strftime('%d-%m-%Y')