4

I have dataframe df

   df.show()
   id|data|somedata
   1 |k   |v
   2 |s   |d
   3 |f   |k
   .
   .
   .

I tried to delete rows from df that id exist in lisst=List(4,9,200) so I used drop like this

   val df1=df.drop(col("id").isin(lisst:_*))

but does'nt work also I tried

   val df1=df.filter(col("id").isin(lisst:_*).drop("id"))

but df1 have same rows in df

1 Answer 1

4

Simply using filter or where with the condition should work; no drop is needed if you don't plan to delete columns:

df.filter(!col("id").isin(lisst:_*))

or:

df.where(!col("id").isin(lisst:_*))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.