Is there any counter method for like() in spark dataframe (something as notLike())?
Or is there any other way to do it except using the traditonal SQL query?
I want to do just the opposite of the following:
df.where(col("_c2").like("XY6%")).show(5)
In Spark & PySpark like() function is similar to SQL LIKE operator that is used to match based on wildcard characters (percentage, underscore) to filter the rows. You can use this function to filter the DataFrame rows by single or multiple conditions, to derive a new column, use it on when().
It worked :)
I had to use the negation operator (~) instead of the 'not' keyword.
df.where(~ col("_c2").like("XY6%")).show(5)
Or you can do :
df.where( col("_c2").like("XY6%") == False ).show(5)
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