how to remove the date from hour in a dataframe code example
Example 1: pandas remove time from datetime
In [37]:
df = pd.DataFrame({'date':['2015-02-21 12:08:51']})
df
Out[37]:
date
0 2015-02-21 12:08:51
In [39]:
df['date'] = pd.to_datetime(df['date']).dt.date
df
Out[39]:
date
0 2015-02-21
Example 2: pandas remove time from date
# If opening_date is currently a timestamp: 2021-01-09 00:00:00
opening_date = pd.to_datetime(opening_date).date()
print(opening_date)
# Result: 2021-01-09