#Function
In PySpark, the isin() function is used to check whether each element in a column is present in a list of values or not. It is often used in DataFrame operations to filter or manipulate data based on the membership of values.

Example: -

# Sample data
data = [("Alice", 25), ("Bob", 30), ("Charlie", 35), ("David", 40)]
columns = ["Name", "Age"]

# Create DataFrame
df = spark.createDataFrame(data, columns)

# Check if Age is in the list [30, 40]
df_filtered = df.filter(df.Age.isin(30, 40))

In PySpark, the .filter(~) syntax is used to negate a condition in a DataFrame filtering operation. The ~ symbol represents logical negation (NOT) in PySpark, and it is commonly used when you want to invert the result of a condition.

DataFrame.filter(~condition)
# Sample data
data = [("Alice", 25), ("Bob", 30), ("Charlie", 35), ("David", 40)]
columns = ["Name", "Age"]

# Create DataFrame
df = spark.createDataFrame(data, columns)

# Filter rows where Age is NOT in [30, 40]
df_filtered = df.filter(~df.Age.isin(30, 40))