df['col'] = pd.to_datetime(df['col'])
df['date_column'] = pd.to_datetime(df['datetime_column']).dt.date
# convert the 'Date' column to datetime format
df['Date']= pd.to_datetime(df['Date'])
# Check the format of 'Date' column
df.info()
pd.to_datetime(df.column)
df['col'] = pd.to_datetime(df['col'])
[dt.to_datetime().date() for dt in df.dates]
import pandas as pd
#create DataFrame
df = pd.DataFrame({'stamps': pd.date_range(start='2020-01-01 12:00:00',
periods=6,
freq='H'),
'sales': [11, 14, 25, 31, 34, 35]})
#convert column of timestamps to datetimes
df.stamps = df.stamps.apply(lambda x: x.date())
#view DataFrame
df
stamps sales
0 2020-01-01 11
1 2020-01-01 14
2 2020-01-01 25
3 2020-01-01 31
4 2020-01-01 34
5 2020-01-01 35
df = pd.DataFrame({'year': [2015, 2016],
'month': [2, 3],
'day': [4, 5]})
pd.to_datetime(df)
0 2015-02-04
1 2016-03-05
dtype: datetime64[ns]