Skip to content

Commit 376bac2

Browse files
Merge pull request #304 from UBC-DSCI/method-clarification
Clarification of method/attribute/operation in intro chapter
2 parents fe3da44 + e967c2a commit 376bac2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

source/intro.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ Fortunately, `pandas` provides the `loc[]` operation, which lets us do just that
553553
The syntax is very similar to the `[]` operation we have already covered: we will
554554
essentially combine both our row filtering and column selection steps from before.
555555
In particular, we first write the name of the data frame---`can_lang` again---then follow
556-
that with the `.loc[]` method. Inside the square brackets,
556+
that with the `.loc[]` operation. Inside the square brackets,
557557
we write our row filtering logical statement,
558558
then a comma, then our list of columns to select.
559559

@@ -576,7 +576,17 @@ and wrote `pd.read_csv`. The dot means that the thing on the left (`pd`, i.e., t
576576
thing on the right (the `read_csv` function). In the case of `can_lang.loc[]`, the thing on the left (the `can_lang` data frame)
577577
*provides* the thing on the right (the `loc[]` operation). In Python,
578578
both packages (like `pandas`) *and* objects (like our `can_lang` data frame) can provide functions
579-
and other objects that we access using the dot syntax.
579+
and other objects that we access using the dot syntax.
580+
581+
```{note}
582+
A note on terminology: when an object `obj` provides a function `f` with the
583+
dot syntax (as in `obj.f()`), sometimes we call that function `f` a *method* of `obj` or an *operation* on `obj`.
584+
Similarly, when an object `obj` provides another object `x` with the dot syntax (as in `obj.x`), sometimes we call the object `x` an *attribute* of `obj`.
585+
We will use all of these terms throughout the book, as you will see them used commonly in the community.
586+
And just because we programmers like to be confusing for no apparent reason: we *don't* use the "method", "operation", or "attribute" terminology
587+
when referring to functions and objects from packages, like `pandas`. So for example, `pd.read_csv`
588+
would typically just be referred to as a function, but not as a method or operation, even though it uses the dot syntax.
589+
```
580590

581591
At this point, if we have done everything correctly, `aboriginal_lang` should be a data frame
582592
containing *only* rows where the `category` is `"Aboriginal languages"`,

0 commit comments

Comments
 (0)