0

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.

partOnepartTwo

  • I am sorry I could not add the actual code due to confidentiality issues with my peers. – Tapasvi Bhatt Jun 03 '20 at 15:59
  • Please, share your code not as an image... this way we cannot reproduce it easily. https://stackoverflow.com/help/how-to-ask By the way, does this answer your question? https://stackoverflow.com/questions/40872090/how-to-delete-rows-in-a-pandas-dataframe? – CarlosSR Jun 03 '20 at 16:02

2 Answers2

0

In pandas, by default drop isn't inplace operation. Try specifying df.drop(j, inplace=True).

pzmn
  • 154
  • 5
0

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

snatchysquid
  • 1,283
  • 9
  • 24