Recall & Review
beginner
How do you select multiple columns from a pandas DataFrame?
You select multiple columns by passing a list of column names inside double square brackets, like
df[["col1", "col2"]].Click to reveal answer
beginner
What type of object is returned when selecting multiple columns from a DataFrame?
Selecting multiple columns returns a new DataFrame containing only those columns.
Click to reveal answer
intermediate
What happens if you select a single column using double square brackets, like
df[["col1"]]?You get a DataFrame with one column, not a Series. Single square brackets return a Series, double brackets return a DataFrame.
Click to reveal answer
intermediate
Can you select columns by position using the same method as selecting by name?
No, selecting by position uses
df.iloc, while selecting by name uses df[[...]].Click to reveal answer
beginner
Why might you want to select multiple columns from a DataFrame?
To focus analysis on specific data, reduce memory use, or prepare data for visualization or modeling.
Click to reveal answer
Which syntax correctly selects columns 'A' and 'B' from DataFrame df?
✗ Incorrect
Use double square brackets with a list of column names to select multiple columns.
What type of object is returned by df[['A', 'B']]?
✗ Incorrect
Selecting multiple columns returns a DataFrame.
How do you select columns by position instead of name?
✗ Incorrect
Use df.iloc with column positions inside a list to select columns by position.
What does df[['A']] return?
✗ Incorrect
Double brackets return a DataFrame, even if selecting one column.
Why is selecting multiple columns useful?
✗ Incorrect
Selecting columns helps focus on relevant data for analysis or visualization.
Explain how to select multiple columns from a pandas DataFrame and what the result looks like.
Think about how you pick multiple items from a list.
You got /2 concepts.
Describe the difference between selecting a single column with single brackets and double brackets in pandas.
Consider the type of object returned.
You got /2 concepts.