Python Homework on Health Data from Nick M

Hi guys, see attached for the code on the health data. Thanks!
Hi Aaron, thanks for the comments.

Regarding the imports, my script can run as written even without specifying
numpy as np. Could this be because I'm using the Spyder IDE?

I guess the delimiter isn't necessary, sort of included it for no special
reason.

The CSV doesn't give a header row and reads in genders, which I'll try to
look into today.

Also, I'll try to dump the imports at the top, I've never seen the
dataframe to CSV since I'm still very new to Python.




On Mon, Aug 11, 2014 at 8:37 AM, Aaron Schumacher <notifications@github.com>
wrote:

> In 06-python/Health_Python_NickM.py:
>
> > +
> > +#Create list that sums health2 and health5
> > +health_2_5 = data.health2 + data.health5
> > +print health_2_5
> > +
> > +#Calculate average male and female age
> > +bygender = data.groupby('gender')
> > +bygender['age'].describe()
> > +
> > +#Collapse gender by average age
> > +collapsed = bygender.aggregate(np.mean)
> > +collapsed2x2 = collapsed.age
> > +print collapsed2x2
> > +
> > +#Write csv with sex and average age
> > +import csv
>
> Generally imports are gathered at the top; also, why did you go back to
> the csv module after starting with pandas? Have you seen DataFrame.to_csv()?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/ajschumacher/gadsdc2/pull/85/files#r16050085>.
>