xxxxxxxxxx
[dt.to_datetime().date() for dt in df.dates]
xxxxxxxxxx
df['date_column'] = pd.to_datetime(df['datetime_column']).dt.date
xxxxxxxxxx
# convert the 'Date' column to datetime format
df['Date']= pd.to_datetime(df['Date'])
# Check the format of 'Date' column
df.info()
xxxxxxxxxx
import pandas as pd
# Assuming you have a data frame called df with a column named 'date' containing object or string data
df['date'] = pd.to_datetime(df['date'])
# If the date column contains any format other than the default format '%Y-%m-%d', specify the format using the 'format' parameter
# For example, if the date format is '%d-%m-%Y', you can use:
# df['date'] = pd.to_datetime(df['date'], format='%d-%m-%Y')
xxxxxxxxxx
df = pd.DataFrame({'date':['31DEC2002','31 December 2015 00:00:00.000 GMT','.']})
df['date'] = pd.to_datetime(df['date'], utc=True, errors='coerce')
print (df)
date
0 2002-12-31 00:00:00+00:00
1 2015-12-31 00:00:00+00:00
2 NaT
xxxxxxxxxx
df['date'] = pd.to_datetime(df['date'], utc=True, errors='coerce')