About this lesson
We discuss how to select individual and multiple columns within a data frame.
Download this lesson’s related exercise files.Selecting Columns and Multiple Columns.docx
57.4 KB Selecting Columns and Multiple Columns - Solution.docx
Selecting Columns and Multiple Columns
Selecting data from a column or specific columns is easy!
When to use
Use this whenever you need to select a column of data, or multiple columns.
Given a dataframe named my_df with columns:
my_cols = ["Mon", "Tues", "Wed"]
To grab a specific column, such as 'Tues':
To Grab more than one column, pass a list of lists:
Hints & tips
- Grab One Column: my_df["Tues"]
- Grab More Than One Column: my_df[["Mon", "Wed"]]
Lesson notes are only available for subscribers.