ComeçarComece de graça

Subsetting rows

A large part of data science is about finding which bits of your dataset are interesting. One of the simplest techniques for this is to find a subset of rows that match some criteria. This is sometimes known as filtering rows or selecting rows.

There are many ways to subset a DataFrame, perhaps the most common is to use relational operators to return True or False for each row, then pass that inside square brackets.

dogs[dogs["height_cm"] > 60]
dogs[dogs["color"] == "tan"]

You can filter for multiple conditions at once by using the "bitwise and" operator, &.

dogs[(dogs["height_cm"] > 60) & (dogs["color"] == "tan")]

homelessness is available and pandas is loaded as pd.

Este exercício faz parte do curso

Manipulação de dados com o pandas

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Filter for rows where individuals is greater than 10000
ind_gt_10k = ____

# See the result
print(ind_gt_10k)
Editar e executar o código