@@ -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 `
156156into 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.
158158Export 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
167167survey_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:
171171weight_year.plot(kind = " bar" )
172172plt.tight_layout() # tip: use this to improve the plot layout.
0 commit comments