1. Learn
  2. /
  3. Courses
  4. /
  5. Survival Analysis in Python

Connected

Exercise

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.

Instructions 1/2

undefined XP
    1
    2
  • Print the first row of the DataFrame to identify the correct column that indicates censorship.
  • Count the number of censored data points in regime_durations and store the result as count.
  • Print count in the console.