QuestionQ113

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Given the code fragment:

div_by_2 = my_df.filter(“number % 2 = 0”)  
print(div_by_2)  

The output of the code fragment is:

DataFrame[nunber: bigint]  

What does this output describe for this transformation in the Apache Spark engine?

Explanation

Spark filter is a transformation that produces a new DataFrame/Dataset representing the filtered rows. Transformations are lazy: Spark records the logical computation and does not execute it until an action is invoked. A DataFrame is a Dataset of rows, and filter is specifically a transformation rather than an action.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!