Azure Databricks:如何在数据框中使用 not like 运算符过滤列?
Azure Databricks : How to filter a column with not like operator in data-frame?
我必须从数据框中排除 Justification 列不包含单词 spare 的行:
"Justification":"WIWYNN | MSASM Spares | 21| MDM: 2520171"
我尝试了以下方法但没有任何效果。(我正在使用 spark python)
df= df.where(~ df["Justification"].like("%spares%"))
df = df.where(~(col("Justification").like("%spare%")))
df = df.where("Justification not like '%spare%'")
结果返回的行中 justification 列中有 spare 字,即使我已经做了否定。
I want exact opposite result
尝试使用以下代码。 Like 是 CaseSensitive。在比较之前需要使用 Lower 函数。
df.where(~(lower(col("Justification")).like("%spare%")))
我必须从数据框中排除 Justification 列不包含单词 spare 的行:
"Justification":"WIWYNN | MSASM Spares | 21| MDM: 2520171"
我尝试了以下方法但没有任何效果。(我正在使用 spark python)
df= df.where(~ df["Justification"].like("%spares%"))
df = df.where(~(col("Justification").like("%spare%")))
df = df.where("Justification not like '%spare%'")
结果返回的行中 justification 列中有 spare 字,即使我已经做了否定。
I want exact opposite result
尝试使用以下代码。 Like 是 CaseSensitive。在比较之前需要使用 Lower 函数。
df.where(~(lower(col("Justification")).like("%spare%")))