Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Dave Foote
/
CAPP30254-1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1f1d026d
authored
Apr 09, 2019
by
Dave Foote
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuck
parent
962f8196
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
pa1.py
pa1.py
View file @
1f1d026d
...
...
@@ -6,6 +6,7 @@ Dave Foote
import
pandas
as
pd
import
matplotlib
as
plt
from
sodapy
import
Socrata
from
shapely.geometry
import
Point
,
Polygon
,
MultiPolygon
#data download helpers
def
get_full_dataset
(
data_set_id
):
...
...
@@ -33,7 +34,23 @@ def make_new_downloads(data_set_id, client, limit, offset):
def
create_df
(
list_of_dicts
):
#takes the full list of crime records and makes a df out of them
return
pd
.
DataFrame
(
list_of_dicts
)
'''
def
get_coordinates
(
df
):
'''
inputs: df with string lat/long columns
creates an associated GeoPandas series of points
'''
longs
=
[
float
(
x
)
for
x
in
df
.
longitude
]
lats
=
[
float
(
x
)
for
x
in
df
.
latitude
]
return
geopandas
.
GeoSeries
([
Point
(
x
)
for
x
in
list
(
zip
(
longs
,
lats
))])
def
get_tracts
(
df_info
,
df_tract
):
'''
inputs: a dataframe with records you'd like to assign tracts to and a dataframe
with boundaries of census tracts (df_tract)
output:
'''
#get the data
id_17
=
'd62x-nvdr'
id_18
=
'3i3m-jwuy'
...
...
@@ -64,8 +81,8 @@ print('Change in Arrest Per Stop Rate from 17-18:\n', (aps_18 - aps_17))
#pull in census tract data from chicago data portal:
id_tract
=
'74p9-q2aq'
df_tract_info
=
create_df
(
get_full_datset
(
id_tract
))
#update 17 and 18 dfs with tracts
df_17.tract = df_17.location.apply()
'''
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment