I have a dataframe in pandas having two fields:
UsageStartDate UsageEndDate
5/1/2020 12:00:00 AM 5/1/2020 11:59:59 PM
I am trying to convert them to 24-hour format.
I am using the following:
df['UsageStartDate'] = pd.to_datetime(df['UsageStartDate'], format='%m/%d/%Y %I:%M:%S %p')
df['UsageEndDate'] = pd.to_datetime(df['UsageEndDate'], format='%m/%d/%Y %I:%M:%S %p')
The UsageEndDate field gives proper output: 2020-05-01 23:59:59
However, the UsageStartDate gives: 2020-05-01
I also tried to parse the date during reading of the csv file:
df = pd.read_csv('./data/sample.csv', parse_dates=['UsageStartDate', 'UsageEndDate'])
It returned the same result as above.
Kindly help.