Get startedGet started for free

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!

This exercise is part of the course

Reshaping Data with pandas

View Course

Exercise instructions

  • 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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(____)
Edit and Run Code