Created
October 31, 2017 15:32
-
-
Save projectyotta/1df5d971e4ef4b0238a396f5001655bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# make sure to install these packages before running: | |
# pip install pandas | |
# pip install sodapy | |
import pandas as pd | |
from sodapy import Socrata | |
# Unauthenticated client only works with public data sets. Note 'None' | |
# in place of application token, and no username or password: | |
client = Socrata("data.smcgov.org", None) | |
# Example authenticated client (needed for non-public datasets): | |
# client = Socrata(data.smcgov.org, | |
# MyAppToken, | |
# userame="user@example.com", | |
# password="AFakePassword") | |
# First 2000 results, returned as JSON from API / converted to Python list of | |
# dictionaries by sodapy. | |
results = client.get("hwna-mxa3", limit=2000) | |
# Convert to pandas DataFrame | |
results_df = pd.DataFrame.from_records(results) | |
print(head(results_df)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment