Skip to content

Commit b45f473

Browse files
authored
Merge pull request #452 from pcoombs55/02-starting-with-data-update
Explains attribute and method
2 parents 92d80c1 + 6458fb4 commit b45f473

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

_episodes/02-starting-with-data.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,18 @@ We'll talk a bit more about what the different formats mean in a different lesso
323323
There are many ways to summarize and access the data stored in DataFrames,
324324
using **attributes** and **methods** provided by the DataFrame object.
325325

326-
To access an attribute, use the DataFrame object name followed by the attribute
327-
name `df_object.attribute`. Using the DataFrame `surveys_df` and attribute
328-
`columns`, an index of all the column names in the DataFrame can be accessed
329-
with `surveys_df.columns`.
330-
331-
Methods are called in a similar fashion using the syntax `df_object.method()`.
332-
As an example, `surveys_df.head()` gets the first few rows in the DataFrame
333-
`surveys_df` using the `head()` method. With a method we can supply extra
334-
information in the parens to control behaviour.
326+
Attributes are features of an object. For example, the `shape` attribute will output
327+
the size (the number of rows and columns) of an object. To access an attribute,
328+
use the DataFrame object name followed by the attribute name `df_object.attribute`.
329+
For example, using the DataFrame `surveys_df` and attribute `columns`, an index
330+
of all the column names in the DataFrame can be accessed with `surveys_df.columns`.
331+
332+
Methods are like functions, but they only work on particular kinds of objects. As
333+
an example, **the `head()` method** works on DataFrames. Methods are called in a
334+
similar fashion to attributes, using the syntax `df_object.method()`. Using
335+
`surveys_df.head()` gets the first few rows in the DataFrame `surveys_df`
336+
using the `head()` method. With a method, we can supply extra information
337+
in the parentheses to control behaviour.
335338

336339
Let's look at the data using these.
337340

0 commit comments

Comments
 (0)