Subsetting columns
When working with data, you may not need all of the variables in your dataset. Square brackets ([]
) can be used to select only the columns that matter to you in an order that makes sense to you.
To select only "col_a"
of the DataFrame df
, use
df["col_a"]
To select "col_a"
and "col_b"
of df
, use
df[["col_a", "col_b"]]
homelessness
is available and pandas
is loaded as pd
.
Este exercício faz parte do curso
Manipulação de dados com o pandas
Exercício interativo prático
Experimente este exercício preenchendo este código de exemplo.
# Select the individuals column
individuals = ____
print(individuals.head())