Since the Where is an alias to Filter it is not highlighted as filter did.
Please find below complete code used in this article.
#DataFrame Creation
from pyspark.sql.functions import *
from pyspark.sql.types import *
data = [(1001,"India","IN"),(1002,"United States","USA"),(1003,"Canada","CAN"),(1004,"Bratain","UK")]
schema = StructType([StructField("ID",IntegerType(),True),\
StructField("Country Name",StringType(),True),\
StructField("Country Code",StringType(),True)])
CountryDF = spark.createDataFrame(data = data, schema = schema)
display(CountryDF)
#Databricks Documentation help
help(CountryDF.filter)
#Display Data Using Filter Method
display(CountryDF.select("*").filter(col("Country Code") == "IN"))
#Display Data Using Where Method
display(CountryDF.select("*").where(col("Country Code") == "IN"))
No comments:
Post a Comment