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 :: dataframe python unique values rows 
Python :: dataframe to tf data 
Python :: how to put song in pygame 
Python :: pandas return row 
Python :: python async partial function 
Python :: buttons on canvas tkinter 
Python :: python ordered dict to dict 
Python :: python pandas get labels 
Python :: python last 3 list elements 
Python :: append object python 
Python :: pandas plot date histogram 
Python :: variable string in string python 
Python :: oversampling using smote 
Python :: python dataclass 
Python :: django model form 
Python :: get scipy version python 
Python :: add key if not exists python 
Python :: how to read files in python with 
Python :: tweepy auth 
Python :: FIND MISSING NUMBER IN AN ARRAY IN PYTHON 
Python :: how to take float input upto 2 decimal points in python 
Python :: Create a single executable from a Python project 
Python :: lagrange polynomial python code 
Python :: django update request.post 
Python :: change index to dataframe pandas 
Python :: python run batch file 
Python :: uppercase string python 
Python :: python tkinter listbox detect selection change 
Python :: traversing a tree in python 
Python :: python turtle 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =