如何获取pyspark中列的特定值?

how to get a specific value of a column in pyspark?

我想要在列 col1 中的值等于 yes 的所有行。在 pandas 我可以这样

df[df['col1']=='yes']

pyspark 怎么样?

您可以使用 DataFrame 中的 filter 方法。

df.filter(df["col1"] == "yes")

df.filter("col1 == 'yes'")