Filtering a Pyspark DataFrame with SQL-like IN clause

前端 未结 5 1646
清酒与你
清酒与你 2020-11-27 02:54

I want to filter a Pyspark DataFrame with a SQL-like IN clause, as in

sc = SparkContext()
sqlc = SQLContext(sc)
df = sqlc.sql(\'SELECT * from my         


        
5条回答
  •  心在旅途
    2020-11-27 03:47

    reiterating what @zero323 has mentioned above : we can do the same thing using a list as well (not only set) like below

    from pyspark.sql.functions import col
    
    df.where(col("v").isin(["foo", "bar"])).count()
    

提交回复
热议问题