DECROMAX

Pandas Between_time function

Nov 22nd, 2021
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. # need to set index as datetime (choose datetime col)
  2. df = df.set_index('Order Date')  
  3.  
  4. # if duplicate datetime values are within index need to remove duplicates to work
  5. df = df[~df.index.duplicated(keep='first')]
  6.  
  7. # filters df beetween range of specified time param (include_start or end= True/False to include specified start time)
  8. df = df.between_time('17:00', '21:00', include_start=True, include_end=False)
Advertisement
Add Comment
Please, Sign In to add comment