LoslegenKostenlos loslegen

A missed phone call

You finished reshaping your churn dataset in the previous exercises. Now, it is ready to be used. You remember that something caught your attention. You are sure you saw a clear pattern in the data.

Before you fit a classification model, you decide to do something simpler. You want to see what else you can learn from the data. You will reshape your data by unstacking levels, but you know this process will generate missing data that you need to handle.

The churn DataFrame contains different features of customers located in Los Angeles and New York, and is available for you. Make sure to examine it in the console!

Diese Übung ist Teil des Kurses

Reshaping Data with pandas

Kurs anzeigen

Anleitung zur Übung

  • Reshape the churn DataFrame by unstacking the level named churn, filling the missing values with zero.
  • Sort the churn DataFrame by the voice_mail_plan column in descending order, then by international_plan column in ascending order.
  • Print the final churn_sorted DataFrame.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Unstack churn level and fill missing values with zero
churn = ____.____(level=____, ____=____)

# Sort by descending voice mail plan and ascending international plan
churn_sorted = churn.____(____=[____, ____], 
                          ____=[____, ____])

# Print final DataFrame and observe pattern
print(____)
Code bearbeiten und ausführen