drop rows of specific time

Question:

    Date              Open        High         Low        Close  Volume 
2022-08-08 09:15:00 17397.39    17443.70    17359.75    17411.06    0   
2022-08-10 13:15:00 17508.28    17532.00    17479.55    17510.24    0   
2022-08-12 09:15:00 17651.81    17680.70    17597.85    17654.14    0   
2022-08-18 09:15:00 17934.37    17954.65    17863.45    17914.30    0   

I have this dataframe . I have to drop the rows when time= 9:15

Asked By: Siddharth Mankar

||

Answers:

Use ~ operator to negate the conditions:

df.Date = pd.to_datetime(df.Date)
df[~((df.Date.dt.hour == 9) & (df.Date.dt.minute == 15))]
Answered By: Nuri Taş
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.