I am trying to drop some specific rows in a DataFrame df
where, the column Time
is anything except 06:00:00
. I tried the following code but it dosen't seem to work. I even tried adding another column Index to my file to aid the process but still it is not working. Can you please help me. I am attaching the screenshots.
The val just contains the specific time 06:00:00
. Also, please ignore the variable req
. Thanks a lot.
In pandas, by default drop
isn't inplace
operation. Try specifying df.drop(j, inplace=True)
.
Have you tried?
df = df.drop(df[//expresion here//].index)
Or even better:
df = df[~df.a.str.contains("06:00:00")]
Where a
is the name of the column you want to search the time in
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.