Lesson Maintainers: Greg Watson
This is an advanced Pandas lesson designed for participants with basic Python programming experience and who have completed the Introduction to Pandas lesson. These lessons can be taught in a day (~ 6 hours).
The concept for this lesson and the original Python scripts were provided by Joseph Kennedy. The city emissions data was compiled by Melissa Allen. We’d like to acknowledge both Joseph’s and Melissa’s contribution to making this training happen!
You are working on a project to determine if the Paris Accord greenhouse gas reduction targets could be met by just the world’s largest cities, because these are the areas with the tax-base and political will to be able to implement many of the carbon changes that would be necessary.
One possible way to do this would be to model the global contribution of expected emissions, and compare this to the emissions that would be produced if the largest cities reduced their emissions by a specified amount, X. Creating a model like this is difficult, so a simpler approach might be to see if the data is already available, calculate the level of greenhouse gas reductions we could get from the cities, and then compare it naively to the IPCC AR5 warming/ppm data. Even if this approach is not completely accurate, it might provide a ball park figure that indicates if the approach would be worth continued exploration.
We’ll start with the following two data sets:
Getting Started
Data Carpentry’s teaching is hands-on, so participants are encouraged to use their own computers to insure the proper setup of tools for an efficient workflow.
These lessons assume no prior knowledge of the skills or tools.To get started, follow the directions in the “Setup” tab to download data to your computer and follow any installation instructions.
Prerequisites
This lesson assumes basic knowledge of Python and completion of the Introduction to Pandas lessons. The following are good measures of the prerequisite skills necessary for this lesson.:
- Software Carpentry Programming with Python
- Plotting and Programming in Python
- Introduction to Pandas
For Instructors
If you are teaching this lesson in a workshop, please see the Instructor notes.
Setup | Download files used in the lesson. | |
00:00 | NetCDF Primer |
How can I import data using Pandas?
What is NetCDF? What tools are available to work with NetCDF? |
00:30 | Using NetCDF with Pandas |
How can I use NetCDF in Pandas?
How should I structure my DataFrame? |
01:20 | Structuring the Data |
How can I improve how the data is structured?
How do I access hierarchical data? How can I combine Series and DataFrames? |
02:10 | Object Oriented Programming |
What is Object Oriented Programming?
What is the difference between a class and an object? How do I define and use classes in Python? |
03:10 | Creating a Class |
How can I use a class to make code reusable?
What do I need to do to turn my code into a class? |
03:45 | Analyzing the Data | How can I use a class to make code reusable? |
04:45 | Visualizing the Data | How can I use classes to make code reusable? |
05:30 | Finish |
The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.