Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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
Comment

how to delete records in pandas before a certain date

df['date'] = pd.to_datetime(df['date'])

res = df[~(df['date'] < '2018-04-01')]

print(res)

   key_value       date
2   value_01 2018-04-02
3   value_01 2018-05-13
4   value_01 2018-05-16
7   value_02 2018-04-01
8   value_02 2018-05-16
9   value_02 2018-05-22
11  value_03 2018-04-14
Comment

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
Comment

pandas remove time from datetime

#Remove time from datetime object by:
df["Date"] = df["Date"].dt.date
Comment

PREVIOUS NEXT
Code Example
Python :: use colabs gpu locally 
Python :: if using and in python 
Python :: print python setencode 
Python :: python set class variable 
Python :: python pool 
Python :: python args description multiple lines 
Python :: import cv2 illegal instruction (core dumped) jetson nano 
Python :: how to use idl in python 
Python :: does the queen brush her teeth 
Python :: Deques in python3 
Python :: how to type shashank in python 
Python :: r stagazer html knit 
Python :: documentation on fasttext gensim python 
Python :: dividing counter object in python 
Python :: jetson nx unable to install matplotlib 
Python :: Math expressions with matplotlib 
Python :: python type hint superclass 
Python :: python to java converter online 
Python :: check status of subprocess 
Python :: poython command options 
Python :: TypeError at /admin/auth/user/ 
Python :: print convert hex as string ascii 
Python :: coger elementos de un string python expresiones regulares 
Python :: assign more than one variable at a time on a single line in python 
Python :: Use Python to calculate (((1+2)*3)/4)^5 
Python :: odoo create new admin user command line 
Python :: add percentage sign to string python 
Python :: Python - Comment jouer le fichier Mp3 
Python :: Constructing a Class with __init__ function 
Python :: OpenCV(3.4.11) Error: Assertion failed (_img.rows * _img.cols == vecSize) in CvCascadeImageReader::PosReader::get 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =