Locked lesson.
About this lesson
Let's discuss how to select specific points within your data frames, such as the intersection of a row and column, or multiple points within different rows and columns.
Exercise files
Download this lesson’s related exercise files.
Selecting Subsets of Rows and Columns.docx57 KB Selecting Subsets of Rows and Columns - Solution.docx
55.4 KB
Quick reference
Selecting Subsets of Rows and Columns
We can select specific data points in a DataFrame as well as specific Subsets.
When to use
Use these methods whenever you want to select a certain point in a dataframe, or a subset of points.
Instructions
To grab a specific point in a DataFrame named my_df, use the loc() function:
my_df.loc["ROW", "COLUMN"]
To grab a subset of points in a DataFrame named my_df:
my_df.loc[["ROW","ROW"], ["COLUMN", "COLUMN"]]
Hints & tips
- my_df.loc["ROW", "COLUMN"]
- my_df.loc[["ROW","ROW"], ["COLUMN", "COLUMN"]]
Lesson notes are only available for subscribers.