Skip to content

Commit

Permalink
Merge pull request #552 from btovar/issue_514
Browse files Browse the repository at this point in the history
Issue 514: clarify iloc and loc
  • Loading branch information
btovar authored May 16, 2023
2 parents 7a74fc1 + a11835c commit 2eb021c
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit 2eb021c

Please sign in to comment.