QuestionQ223

VerifiedData Processing & Transformations

A data engineer must calculate metrics such as:

  • rolling 7-day sales
  • percentage of total revenue
  • top-N most profitable categories

Which two approaches are suitable for implementing these metrics with PySpark DataFrames?

Choose two
Explanation

PySpark window specifications support ordered frames for rolling aggregations, and ranking functions such as rank operate within a window partition, making them suitable for rolling sales and top-N category calculations. Percentage-of-total metrics can be computed by aggregating revenue with groupBy, joining the resulting totals to the applicable data, and dividing each revenue value by its total.

Learn more

Community Discussion

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