Kom igångKom igång gratis

BMI of villains

Let's return to the heroes dataset containing the information on different comic book heroes. We added a bmi column to the dataset calculated as Weight divided by (Height/100)**2. This index helps define whether an individual has weight problems.

Your task is to find out what is the mean value and standard deviation of the BMI index depending on the character's 'Alignment' and the 'Publisher' whom this character belongs to. However, you'll need to consider only those groups that have more than 10 valid observations of the BMI index.

Tip: use .count() to calculate the number of valid observations.

Den här övningen är en del av kursen

Practicing Coding Interview Questions in Python

Visa kurs

Övningsinstruktioner

  • Group the data by the two factors specified above.
  • Filter groups having more than 10 valid bmi observations.
  • Group the filtered data again by the same factors.
  • Calculate the mean and standard deviation of the BMI index.

Interaktiv övning med praktiskt arbete

Testa den här övningen genom att slutföra den här exempelkoden.

import numpy as np

# Group the data by two factors specified in the context
groups = ____

# Filter groups having more than 10 valid bmi observations
fheroes = ____

# Group the filtered data again by the same factors
fgroups = ____

# Calculate the mean and standard deviation of the BMI index
result = fgroups[____].____
print(result)
Redigera och kör kod