Editing Community Data Science Workshops (Spring 2015)/Day 2 Lecture
From CommunityData
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
[[File:Place bear-500x650.jpeg|200px|thumb|In which you learn how to use Python and web APIs to meet the likes of these guys!]] | [[File:Place bear-500x650.jpeg.jpeg|200px|thumb|In which you learn how to use Python and web APIs to meet the likes of these guys!]] | ||
== Lecture Outline == | == Lecture Outline == | ||
Line 12: | Line 12: | ||
* What did we learn in Session 1? | * What did we learn in Session 1? | ||
* New data type: Tuple! | |||
* What is an API? | * What is an API? | ||
* How do we use one to fetch interesting datasets? | * How do we use one to fetch interesting datasets? | ||
Line 65: | Line 66: | ||
; New programming concepts: | ; New programming concepts: | ||
* interpolate variables into a string using | * interpolate variables into a string using % and %()s | ||
* | * requests | ||
* open files and write to them | * open files and write to them | ||
* parsing a string (turning the string into a data structure we can manipulate) | * parsing a string (turning the string into a data structure we can manipulate) | ||
Line 79: | Line 80: | ||
** bears of different sizes | ** bears of different sizes | ||
** bears in greyscale or color | ** bears in greyscale or color | ||
* Now we write a small program to grab an arbitrary square from placebear by asking for the size on standard in ([http://mako.cc/teaching/2015/cdsw-spring/ | * Now we write a small program to grab an arbitrary square from placebear by asking for the size on standard in ([http://mako.cc/teaching/2015/cdsw-spring/placebear_raw_input.py placebear_raw_input.py]) | ||
Line 85: | Line 86: | ||
* what is json: useful for more structured data | * what is json: useful for more structured data | ||
* import json; json.loads() | * import json; json.loads() | ||
* like Python (except no single quotes) | * like Python (except no single quotes) | ||
* simple lists, dictionaries | * simple lists, dictionaries | ||
Line 108: | Line 109: | ||
* [http://mako.cc/teaching/2014/cdsw-autumn/lecture2-web_apis.pdf Slides (PDF)] — For viewing | * [http://mako.cc/teaching/2014/cdsw-autumn/lecture2-web_apis.pdf Slides (PDF)] — For viewing | ||
* [http://mako.cc/teaching/2014/cdsw-autumn/lecture2-web_apis.odp Slides (ODP Libreoffice Slides Format)] — For editing and modification | * [http://mako.cc/teaching/2014/cdsw-autumn/lecture2-web_apis.odp Slides (ODP Libreoffice Slides Format)] — For editing and modification | ||