Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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

PREVIOUS NEXT
Code Example
Python :: how to check if everything inside a list is unique 
Python :: python3 return a list of indexes of a specific character in a string 
Python :: python text fromatting rows 
Python :: youtube-dl python download to specific folder 
Python :: print the number of times that the substring occurs in the given string 
Python :: how to log ip addresses in django 
Python :: Entry border color in tkinter 
Python :: semicolons in python 
Python :: trimming spaces in string python 
Python :: pygame mute import message 
Python :: how to get the mouse input in pygame 
Python :: python pandas convert comma separated number string to integer list 
Python :: pandas change every row to df 
Python :: raise an APi error on django rest view 
Python :: jupyter notebook play audio 
Python :: jsonresponse status code django 
Python :: all subarrays of an array python 
Python :: selenium how to handle element not found python 
Python :: Incorrect number of bindings supplied. The current statement uses 1, and there are 3 supplied. 
Python :: add a column while iterating rows pandas 
Python :: python get lan ip 
Python :: how to import iris dataset 
Python :: pygame.display.flip vs update 
Python :: python for loop max iterations 
Python :: python 3.9.5 installed update default version 
Python :: show battery of my laptop python 
Python :: python cv2.Canny() 
Python :: qmessagebox icon pyqt5 
Python :: python candlestick chart 
Python :: read pdf py 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =