Answers for "drop time in datetime python"

2

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
Posted by: Guest on June-28-2020
0

how to remove time in datetime in python

import datetime
date_and_time = datetime.datetime(2019, 12, 30)
date = date_and_time.date()
print(date)
Posted by: Guest on September-13-2021

Python Answers by Framework

Browse Popular Code Answers by Language