Skip to content

Commit a1bda53

Browse files
committed
03-index-slice-subset.md: cleaning up
1 parent e9a5210 commit a1bda53

1 file changed

Lines changed: 23 additions & 17 deletions

File tree

_episodes/03-index-slice-subset.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,27 @@ objectives:
1212
- "Employ label and integer-based indexing to select ranges of data in a dataframe."
1313
- "Reassign values within subsets of a DataFrame."
1414
- "Create a copy of a DataFrame."
15-
- "Query /select a subset of data using a set of criteria using the following operators: =, !=, >, <, >=, <=."
15+
- "Query / select a subset of data using a set of criteria using the following operators:
16+
`=`, `!=`, `>`, `<`, `>=`, `<=`."
1617
- "Locate subsets of data using masks."
1718
- "Describe BOOLEAN objects in Python and manipulate data using BOOLEANs."
1819
keypoints:
19-
- "In Python, portions of data can be accessed using indices, slices, column headings, and condition-based subsetting."
20-
- "Python uses 0-based indexing, in which the first element in a list, tuple or any other data structure has an index of 0."
21-
- "Pandas enables common data exploration steps such as data indexing, slicing and conditional subsetting."
22-
20+
- "In Python, portions of data can be accessed using indices, slices, column headings, and
21+
condition-based subsetting."
22+
- "Python uses 0-based indexing, in which the first element in a list, tuple or any other data
23+
structure has an index of 0."
24+
- "Pandas enables common data exploration steps such as data indexing, slicing and conditional
25+
subsetting."
2326
---
2427

25-
In lesson 01, we read a CSV into a Python pandas DataFrame. We learned:
28+
In the first episode of this lesson, we read a CSV file into a pandas' DataFrame. We learned how to:
2629

27-
- how to save the DataFrame to a named object,
28-
- how to perform basic math on the data,
29-
- how to calculate summary statistics, and
30-
- how to create plots of the data.
30+
- save a DataFrame to a named object,
31+
- perform basic math on data,
32+
- calculate summary statistics, and
33+
- create plots based on the data we loaded into pandas.
3134

32-
In this lesson, we will explore **ways to access different parts of the data**
33-
using:
35+
In this lesson, we will explore ways to access different parts of the data using:
3436

3537
- indexing,
3638
- slicing, and
@@ -39,7 +41,7 @@ using:
3941
## Loading our data
4042

4143
We will continue to use the surveys dataset that we worked with in the last
42-
lesson. Let's reopen and read in the data again:
44+
episode. Let's reopen and read in the data again:
4345

4446
~~~
4547
# Make sure pandas is loaded
@@ -100,11 +102,15 @@ surveys_df['speciess']
100102
~~~
101103
{: .language-python}
102104

103-
Python tells us what type of error it is in the traceback, at the bottom it says `KeyError: 'speciess'` which means that `speciess` is not a column name (or Key in the related Python data type dictionary).
105+
Python tells us what type of error it is in the traceback, at the bottom it says
106+
`KeyError: 'speciess'` which means that `speciess` is not a valid column name (nor a valid key in
107+
the related Python data type dictionary).
104108

105109
## Extracting Range based Subsets: Slicing
106110

107-
**REMINDER**: Python Uses 0-based Indexing
111+
> ## Reminder
112+
> Python uses 0-based indexing.
113+
{: .callout}
108114

109115
Let's remind ourselves that Python uses 0-based
110116
indexing. This means that the first element in an object is located at position
@@ -458,8 +464,8 @@ x == 5
458464
~~~
459465
{: .language-python}
460466
461-
When we ask Python whether `x` is greater than 5, it returns `False`.
462-
This is Python's way to say "No". Indeed, the value of `x` is 5,
467+
When we ask Python whether `x` is greater than 5, it returns `False`.
468+
This is Python's way to say "No". Indeed, the value of `x` is 5,
463469
and 5 is not greater than 5.
464470
465471
To create a boolean mask:

0 commit comments

Comments
 (0)