Which of the following describes the relationship between native Spark DataFrames and pandas API on Spark DataFrames?
To filter rows in a Spark DataFrame based on a condition, the filter method is used. In this case, the condition is that the value in the 'discount' column should be less than or equal to 0. The correct syntax uses the filter method along with the col function from pyspark.sql.functions.
Correct code:
from pyspark.sql.functions import col filtered_df = spark_df.filter(col('discount') <= 0)
Option A and D use Pandas syntax, which is not applicable in PySpark. Option B is closer but misses the use of the col function.
Haydee
7 months agoShawnna
8 months agoLaurene
8 months agoJoanna
8 months agoMing
8 months agoVerona
9 months agoHarrison
9 months agoLindsay
9 months agoLeatha
9 months agoKathrine
9 months agoAlonzo
9 months agoGilma
9 months agoBethanie
9 months agoNenita
9 months agoJustine
1 year agoNobuko
1 year agoLonna
1 year agoMarshall
1 year agoJoseph
1 year agoCarylon
1 year agoDeandrea
1 year agoKarima
1 year agoStephanie
1 year agoVeronika
1 year agoCorrina
1 year agoAdolph
1 year agoYolande
1 year agoTayna
1 year agoDaren
1 year agoKenda
1 year agoLauna
1 year agoTalia
1 year agoSkye
1 year agoIlene
1 year agoIlene
1 year agoKyoko
1 year agoCharolette
1 year agoKyoko
1 year ago