Skip to content

Instantly share code, notes, and snippets.

View stiles's full-sized avatar

Matt Stiles stiles

View GitHub Profile
@stiles
stiles / pandas.py
Last active September 18, 2024 23:21
Pandas cheat sheet
# List unique values in a DataFrame column
df['Column Name'].unique()
# To extract a specific column (subset the dataframe), you can use [ ] (brackets) or attribute notation.
df.height
df['height']
# are same thing!!! (from http://www.stephaniehicks.com/learnPython/pages/pandas.html
# -or-
# http://www.datacarpentry.org/python-ecology-lesson/02-index-slice-subset/)
university total_salary
Chicago State University 26643267.07
Eastern Illinois University 39104962.4
Governors State University 27282001.7
Illinois State University 92108974.46
Northeastern Illinois University 38303671.72
Northern Illinois University 93582392.05
Southern Illinois University Carbondale 74338384.24
Southern Illinois University Edwardsville 64287003.19
Southern Illinois University School of Medicine 72072277.63
@stiles
stiles / homeless_victims_maps.geojson
Last active November 6, 2019 21:48
Homeless crime victims, by LA neighborhood, 2018-2019
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stiles
stiles / buffer_area.geojson
Created October 30, 2019 22:02
Five-mile buffer around 69 Bravo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stiles
stiles / buildings_in_buffer.geojson
Created October 30, 2019 22:01
Buildings in five-mile radius around 69 Bravo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stiles
stiles / refuse.csv
Last active October 17, 2019 21:08
Daily 'refuse' picked up by LA City
id generalcommodity date value
0 Refuse 2016-01-02 3372.0
1 Refuse 2016-01-03 36.0
2 Refuse 2016-01-04 3366.0
3 Refuse 2016-01-05 3543.0
4 Refuse 2016-01-06 3461.0
5 Refuse 2016-01-07 3340.0
6 Refuse 2016-01-08 3149.0
7 Refuse 2016-01-09 30.0
8 Refuse 2016-01-10 43.0
@stiles
stiles / halfmile_mapshaper.json
Created October 9, 2019 00:22
Topojson: city of LA half-mile hexbins
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stiles
stiles / los-angeles-city-half-mile-topo.json
Last active October 9, 2019 00:15
LA City hex bins 1/2 mile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stiles
stiles / la_bins_sit_lie_csv.csv
Created October 9, 2019 00:04
Sit-lie arrests by year and hexbin id
nuid id total year
0 4139 1 2015
1 4141 3 2013
2 4146 2 2012
3 4159 2 2012
4 4157 18 2016
5 4156 3 2017
6 4156 1 2019
7 4156 1 2018
8 4183 1 2012
@stiles
stiles / la_bins_sit_lie_clean.geojson
Last active October 9, 2019 00:01
LA city half-mile hexbins with sit-lie arrest data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.