Repo for Georgetown McCourt's School of Public Policy's Data Science I (PPOL 564) in Fall of 2022
These are jupyter notebook-based activities to practice Python or other concepts, along with accompanying slides:
- 00_introclass.ipynb
- Concepts covered:
- Creating variables
- Checking types
- Lists
- Basic list comprehension
- Basic numpy arrays
- Slides: 01_ppol564_f22_intro_pythonbasics.pdf
- Concepts covered:
-
01_pandas_datacleaning_blank.ipynb
- Data: DC crime reports in 2020
- Concepts covered:
- Aggregation using
groupby
andagg
- Lambda functions within aggregation
- Recoding variables using
np.where
- Recoding variables using
np.select
- Recoding variables using
map
and dictionary
- Aggregation using
- Slides: 02_ppol564_f22_datawrangling.pdf
- Solutions: 01_pandas_datacleaning_solutions.ipynb
-
02_functions_part1_blank.ipynb
- Data: DC crime reports in 2020
- Concepts covered:
- user-defined function to find matches within a broader pool of data
- using list comprehension to apply a function iteratively over list elements
- Slides: 03_ppol564_f22_userdefinedfunctions_part1.pdf
- Solutions: 02_functions_part1_solutions.ipynb
-
03_plottingexamples_plotnine.ipynb
- Data: DC crime reports in 2020
- Concepts covered:
- Bar chart
- Line graph
- Coloring and/or faceting by group
-
04_latex_output_examples_blank.ipynb
- Data: DC crime reports in 2020
- Concepts covered:
- Creating tables to export to LaTeX
- Saving figures to export
- Using user-defined function to iterate over entities and efficiently save many figures
- Solutions: 04_latex_output_examples_solutions.ipynb
-
- Data: simulated data
- Concepts covered:
- Methods versus attributes
- Reshaping using
pivot
andpivot_table()
- User-defined functions and if/elif/else control flow
- Solutions: 05_reviewsession_solutions.ipynb
-
06_reshaping_merging_blank.ipynb
- Data: San Diego business tax certificate data; Census NAICS code data
- Concepts covered:
- Reshaping between long and wide
- Data cleaning such as extraneous rows/columns
- Recasting join cols to allow join (e.g., converting
int
to character) pd.merge
and different types of exact joins using join keys- Post-merge diagnostics
- Slides: 05_ppol564_f22_mergereshape.pdf
- Solutions: 06_reshaping_merging_solutions.ipynb
-
- Data: Food Research Action Center (FRAC) data on district and school's election of community eligibility provision (CEP) for Free or Reduced Price Lunch (FRPL)
- Concepts covered:
- Pattern construction using
re
module re.sub
for replacementre.findall
re.match
and how to work with match objects using.group()
- Throughout, review of list comprehension
- Pattern construction using
- Slides: 06_ppol564_f22_regex.pdf
- Solutions: 07_regex_solutions.ipynb