Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 514: clarify iloc and loc #552

Merged
merged 1 commit into from
May 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions episodes/03-index-slice-subset.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,13 @@ surveys_df = pd.read_csv("data/surveys.csv")
We can select specific ranges of our data in both the row and column directions
using either label or integer-based indexing.

- `loc` is primarily *label* based indexing. *Integers* may be used but
they are interpreted as a *label*.
- `iloc` is primarily *integer* based indexing
- `iloc` is primarily an *integer* based indexing counting from 0. That is, your
specify rows and columns giving a number. Thus, the first row is row 0,
the second column is column 1, etc.

- `loc` is primarily a *label* based indexing where you can refer to rows and
columns by their name. E.g., column 'month'. Note that *integers* may be
used, but they are interpreted as a *label*.

To select a subset of rows **and** columns from our DataFrame, we can use the
`iloc` method. For example, we can select month, day and year (columns 2, 3
Expand Down