Get startedGet started for free

First look at censored data

You are the lead data scientist at the national government of a small country named Data Land. You are helping write the law on how long presidencies should last. Because your country relies on data for every decision, you seek wisdom from a DataFrame of 1808 regimes across 202 countries, called regime_durations. How long do regimes tend to last? The fate of your country lies between the rows and in your hands…

Your goal is to calculate the average duration. Because you are using a time-to-event dataset, you will need to inspect the data to check for censorship.

The pandas package is loaded as pd. The durations DataFrame is loaded and stored as regime_durations. You can use the console to view the DataFrame's column names.

This exercise is part of the course

Survival Analysis in Python

View Course

Hands-on interactive exercise

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

# Print first row
print(regime_durations.____)

# Count censored data
count = len(regime_durations[regime_durations[____] == ____])

# Print the count to console
print(____)
Edit and Run Code