I have a dataframe with multiple columns
df = pd.DataFrame({'date': ['2011-01-01 10:15:20', '2016-11-17 08:22:10'],
'text': ['red', 'purple'],
'datetime': ['2011-01-01 10:15:20', '2016-11-17 08:22:10']})
I want to export this df to a csv file using pandas' .to_csv(...) and save the column date in the format %Y-%m-%d but the column datetime in the format %Y-%m-%d %H:%M:%S and can't find a way to modify the code accordingly.
I have tried
df.to_csv('output.csv', date_format = '%Y-%m-%d'), which transforms all columns' date format, including the columndatetime, where I want to keep the time.df.to_csv('output.csv')(without usingdate_format = ...) displays all columns' date format as datetime - yet I want the columndateto not carry the time-component.
Does anyone have an idea of how to do this? Thanks a ton in advance.