Skip to content

Commit 0122883

Browse files
committed
differences for PR #626
1 parent 5153486 commit 0122883

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

05-merging-data.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,24 +149,24 @@ new_output = pd.read_csv('data/out.csv', keep_default_na=False, na_values=[""])
149149

150150
### Challenge - Combine Data
151151

152-
In the data folder, there is another folder called `yearly_files`
153-
that contains survey data broken down into individual files by year.
154-
Read the data from two of these files,
155-
`surveys2001.csv` and `surveys2002.csv`,
152+
In the data folder, there are additional files
153+
that contain survey data broken down into individual files by year.
154+
Read the data from
155+
`surveys2001.csv` and `surveys2002.csv`
156156
into pandas and combine the files to make one new DataFrame.
157-
Create a plot of average plot weight by year grouped by sex.
157+
Create a plot of average weight by year grouped by sex.
158158
Export your results as a CSV and make sure it reads back into pandas properly.
159159

160160
::::::::::::::::::::::: solution
161161

162162
```python
163163
# read the files:
164-
survey2001 = pd.read_csv("data/yearly_files/surveys2001.csv")
165-
survey2002 = pd.read_csv("data/yearly_files/surveys2002.csv")
164+
survey2001 = pd.read_csv("data/surveys2001.csv")
165+
survey2002 = pd.read_csv("data/surveys2002.csv")
166166
# concatenate
167167
survey_all = pd.concat([survey2001, survey2002], axis=0)
168168
# get the weight for each year, grouped by sex:
169-
weight_year = survey_all.groupby(['year', 'sex']).mean()["wgt"].unstack()
169+
weight_year = survey_all.groupby(['year', 'sex']).mean()["weight"].unstack()
170170
# plot:
171171
weight_year.plot(kind="bar")
172172
plt.tight_layout() # tip: use this to improve the plot layout.

md5sum.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"episodes/02-starting-with-data.md" "7aae8d49ef03e5c65d66cc0104ddbf10" "site/built/02-starting-with-data.md" "2024-02-23"
1010
"episodes/03-index-slice-subset.md" "3085c53ba22bacb5ecf486aedefa4a8c" "site/built/03-index-slice-subset.md" "2025-04-29"
1111
"episodes/04-data-types-and-format.md" "e57b9b771e5d2dcf4c9e2521822f8d5a" "site/built/04-data-types-and-format.md" "2023-06-05"
12-
"episodes/05-merging-data.md" "8491d51a41ad970f69acac6162e97432" "site/built/05-merging-data.md" "2024-02-21"
12+
"episodes/05-merging-data.md" "b23ea51f59e06fb1bbf2eb0af3d842b8" "site/built/05-merging-data.md" "2025-06-27"
1313
"episodes/06-loops-and-functions.md" "d41f11e6c162c86393cd9bd4431c0687" "site/built/06-loops-and-functions.md" "2023-05-18"
1414
"episodes/07-visualization-ggplot-python.md" "be85fc2fd560b30bee0818ecf4a4e712" "site/built/07-visualization-ggplot-python.md" "2024-03-29"
1515
"episodes/08-putting-it-all-together.md" "b279a4ab47789abda7f71609a78022ed" "site/built/08-putting-it-all-together.md" "2024-01-31"

0 commit comments

Comments
 (0)