forked from codeforsanjose/Indicators
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
32 lines (27 loc) · 879 Bytes
/
Copy pathapi.py
File metadata and controls
32 lines (27 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import requests
from requests.auth import HTTPBasicAuth
import pandas
apikey = "d8fa9f7c0841efecfb91b98bf8cbe056cf654cec"
request_url = "http://citysdk.commerce.gov"
def main():
request_obj = {
'zip': '21401',
'state': 'MD',
'level': 'state',
'sublevel': False,
'api': 'acs5',
'year': 2010,
'variables': ['income', 'population']
}
response = requests.post(request_url, auth=HTTPBasicAuth(apikey, None), json=request_obj)
data_gotten = response.json()
types = data_gotten['type']
features = data_gotten['features']
totals = data_gotten['totals']
panda_data = pandas.DataFrame(features)
"""
pandas takes series data meaning a big array of stuffs not dicts so need
to get array of data then stick into pandas for parsing i guesst
"""
if __name__ == "__main__":
main()