Skip to content

Commit a11835c

Browse files
committed
clarify introduction of iloc and loc
1 parent 6e4b731 commit a11835c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

episodes/03-index-slice-subset.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,13 @@ surveys_df = pd.read_csv("data/surveys.csv")
283283
We can select specific ranges of our data in both the row and column directions
284284
using either label or integer-based indexing.
285285

286-
- `loc` is primarily *label* based indexing. *Integers* may be used but
287-
they are interpreted as a *label*.
288-
- `iloc` is primarily *integer* based indexing
286+
- `iloc` is primarily an *integer* based indexing counting from 0. That is, your
287+
specify rows and columns giving a number. Thus, the first row is row 0,
288+
the second column is column 1, etc.
289+
290+
- `loc` is primarily a *label* based indexing where you can refer to rows and
291+
columns by their name. E.g., column 'month'. Note that *integers* may be
292+
used, but they are interpreted as a *label*.
289293

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

0 commit comments

Comments
 (0)