I have a pandas DataFrame from 6:36 AM to 5:31 PM. I want to remove all observations where the time is less than 8:00:00 AM. Here is my attempt:
df = df[df.index < '2013-10-16 08:00:00']
This does nothing, please help.
between_time() is a Pandas DataFrame method that filters for rows in a Pandas DataFrame between a start and end time. The parameters are: start_time : datetime. time or str.
To sort a Pandas DataFrame by index, you can use DataFrame. sort_index() method. To specify whether the method has to sort the DataFrame in ascending or descending order of index, you can set the named boolean argument ascending to True or False respectively. When the index is sorted, respective rows are rearranged.
You want df.loc[df.index < '2013-10-16 08:00:00']
since you're selecting by label (index) and not by value.
selecting by label
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With