CommencerCommencer gratuitement

Phone directory index

After reshaping the dataset, you sent it to your colleagues and asked them to fill in some data. Now, they sent the new churn dataset back and you realized that its shape has changed.

Before you go on, you need to do some reshaping again. The dataset contains a multi-level index in the columns. You'd like to have some columns set as the row index. Also, this time you will only stack some levels. You believe it will help you discover some patterns in the data.

The DataFrame churn is available for you. It contains data about state, city, total_day_calls and total_day_minutes during day and night time. Make sure to examine it in the console!

Cet exercice fait partie du cours

Reshaping Data with pandas

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Set state and city as index modifying the DataFrame
churn.____([____, ____], ____=____)

# Print churn
print(churn)
Modifier et exécuter le code