'Setting the date time format to multiple columns of a dataframe at once Python
I have two columns in my DataFrame which I format to a specific time format. It works with two lines of code below but I want to combine into one command
df['Time01'] = pd.to_datetime(Time_01).strftime('%H:%M:%S')
df['Time02'] = pd.to_datetime(Time_02).strftime('%H:%M:%S')
I have tried the following
df[['Time_01','Time_02']].apply(pd.to_datetime, format = '%H:%M:%S')
But get the following error message
None of [Index(['Time_01', 'Time_02'], dtype='object')] are in the [columns]
New python and pandas any help appreciated
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
