Skip to content
This repository has been archived by the owner on Jan 3, 2018. It is now read-only.

Worked example of working with climate data (wrap-up to novice Python lesson) #382

Merged
merged 18 commits into from
Apr 21, 2014
Merged

Worked example of working with climate data (wrap-up to novice Python lesson) #382

merged 18 commits into from
Apr 21, 2014

Conversation

gvwilson
Copy link
Contributor

This PR contains a capstone lesson for the novice Python material that shows how to use requests, cStringIO, csv, and the World Bank's Climate Data API to download data from the web and do some simple analysis with it.

left_data = get_country_temperatures(left_country)
right_data = get_country_temperatures(right_country)
result = []
for ( (left_year, left_value), (right_year, right_value) ) in zip(canada, brazil):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should probably be

for ( (left_year, left_value), (right_year, right_value) ) in zip(left_country, right_country):

@lexnederbragt
Copy link
Contributor

I like the example. It shows combining importing modules, fetching data, parsing data, writing functions and unit tests.

Why not add some plotting? For example, the temperatures over time for the two countries? Makes for a more appealing example, imho...

@PBarmby
Copy link
Contributor

PBarmby commented Apr 7, 2014

Looks good, comments below all minor things.

Possible typos:
"First 100 characters of data is" -> "first 100 characters of data are"
"Python stops executed" -> "Python stops executing"

I wonder if there are more intuitive names than "reader" and "wrapper":
wrapper = csv.reader(reader)
may be a bit too terse for people?

instead of
if record[0] != 'year':
you could also test the datatype of records (but maybe you don't want to go there)

Re: left and right in section 5/6: I haven't seen it done with this syntax before (I would probably just use x1 and x2, or something) but maybe that's just me. Is there any dnager of left/right here being confused with other things, like the left-most characters in a string, etc?

Minor wording changes which I think help clarify:
"it can switch back & forth" --> "it can switch back & forth between these two approaches"
"how we could do this using a couple of standard Python libraries" --> "how we could parse the data using a couple of standard Python libraries"

"Escape sequences" box: important info but I think it disrupts the flow a bit.

gvwilson pushed a commit that referenced this pull request Apr 21, 2014
Worked example of working with climate data (wrap-up to novice Python lesson)
@gvwilson gvwilson merged commit ecb72d4 into swcarpentry:master Apr 21, 2014
@gvwilson gvwilson deleted the worked-example branch April 21, 2014 13:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants