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
6 months agoShawnna
6 months agoLaurene
6 months agoJoanna
7 months agoMing
7 months agoVerona
7 months agoHarrison
7 months agoLindsay
7 months agoLeatha
8 months agoKathrine
8 months agoAlonzo
8 months agoGilma
8 months agoBethanie
8 months agoNenita
8 months agoJustine
1 year agoNobuko
11 months agoLonna
11 months agoMarshall
12 months agoJoseph
1 year agoCarylon
1 year agoDeandrea
11 months agoKarima
11 months agoStephanie
12 months agoVeronika
1 year agoCorrina
12 months agoAdolph
1 year agoYolande
1 year agoTayna
1 year agoDaren
11 months agoKenda
12 months 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