Menu
CoddyTech

Recap: Team Totals

Part of the Fundamentals section of Coddy's PySpark journey. Lesson 14 of 18.

challenge icon

Challenge

Easy

Exclude records whose amount is null or less than zero. Group the remaining records by team and sum amount as total. Return team, total, sorted by total descending and team ascending for ties. Team names are non-null.

Write transform(df) and return a Spark DataFrame. The checker supplies df with schema team string, amount int. The session and F (PySpark functions) are already available. Do not print; the checker displays the returned rows. Return columns in this order: team, total.

Try it yourself

def transform(df):
    return df

All lessons in Fundamentals

Practice on your own: Online Python compiler