You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/charts.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,7 +130,7 @@ What important facet of the data is this chart *not* showing? There are two Robi
130
130
We have that `latimes_make` column in our original dataframe, but it got lost when we created our ranking because we didn't include it in our `groupby` command. We can fix that by scrolling back up our notebook and adding it to the command. You will need to replace what's there with a list containing both columns we want to keep.
Rerun all of the cells below to update everything you're working with. Now if you inspect the ranking you should see the `latimes_make` column included.
Copy file name to clipboardExpand all lines: docs/src/columns.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ kernelspec:
16
16
17
17
# Columns
18
18
19
-
We’ll begin with the `latimes_make_and_model` column, which records the standardized name of each helicopter that crashed. To access its contents separate from the rest of the DataFrame, append a period to the variable followed by the column’s name.
19
+
We’ll begin with the `latimes_make_and_model` column, which records the standardized name of each helicopter that crashed. To access its contents separate from the rest of the DataFrame, append a pair of flat brackets with the column’s name in quotes inside.
That will list the column out as a `Series`, just like the ones we created from scratch earlier. Just as we did then, you can now start tacking on additional methods that will analyze the contents of the column.
34
34
35
35
````{note}
36
-
You can also access columns a second way, like this: `accident_list['latimes_make_and_model']`. This method isn’t as pretty, but it’s required if your column has a space in its name, which would break the simpler dot-based method.
36
+
You can also access columns a second way, like this: `accident_list.latimes_make_and_model`. This method is quicker to type, but it won't work if your column has a space in its name. So we're teaching the universal bracket method instead.
37
37
````
38
38
39
39
## Count a column's values
@@ -44,7 +44,7 @@ There’s another built-in pandas tool that will total up the frequency of value
Congratulations, you've made your first finding. With that little line of code, you've calculated an important fact: During the period being studied, the Robinson R44 had more fatal accidents than any other helicopter.
@@ -55,7 +55,7 @@ You may notice that even though the result has two columns, pandas did not retur
The resulting series can be added to your dataframe by assigning it to a new column. You name your column by providing it as a quoted string inside of flat brackets. Let's call this column something brief and clear like `per_hour`.
Copy file name to clipboardExpand all lines: docs/src/filters.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,14 +40,14 @@ In the next cell we will ask pandas to narrow down our list of accidents to just
40
40
41
41
```{code-cell}
42
42
:tags: [show-input]
43
-
accident_list[accident_list.state == my_state]
43
+
accident_list[accident_list['state'] == my_state]
44
44
```
45
45
46
46
Now we should save the results of that filter into a new variable separate from the full list we imported from the CSV file. Since it includes only the sites for the state we want, let’s call it `my_accidents`.
You can clean up the `0` column name assigned by pandas with the `rename` method. The `inplace` option, found on many pandas methods, will save the change to your variable automatically.
0 commit comments