I'm trying to convert one of the Column in CSV which is for Date/timestamp in the format 12/30/2023 22:13 to a required format 2023-12-30T22:13:39Z.
So far got this:
import pandas as pd
df = pd.read_csv('input.csv', na_filter=False, skiprows=0)
print(df)
df['datetime'] = pd.to_datetime(df['datetime'])
print(df)
This gets me Date/time in format of 2023-12-30 22:13:00.
There is a 'format' in to_datetime() documentation (https://pandas.pydata.org/docs/reference/api/pandas.to_datetime.html), Tried this but this does not work.
df['datetime'] = pd.to_datetime(df['datetime'], format='%Y-%m-%dT%H:%M:%sZ', errors='coerce')
This Python - Pandas - Convert YYYYMM to datetime closet I found to what I needed but cannot make it work.
Please someone help.