Last active
April 26, 2020 05:27
-
-
Save Hugheym/3953402a69df0c3b1e5e8ff0c3d551aa to your computer and use it in GitHub Desktop.
For tutorial
This file contains hidden or 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
| %python | |
| # Use dbutils to install sodapy, and mapboxgl from the python package index (we can also do this in the cluster settings page) | |
| dbutils.library.installPyPI("sodapy") #sodapy is a client for Socrata Open Data API. | |
| dbutils.library.installPyPI("mapboxgl") #mapboxgl is used for rendering interactive maps. | |
| import pandas as pd | |
| from sodapy import Socrata | |
| # Unauthenticated client only works with public data sets. | |
| client = Socrata("data.cityofnewyork.us", None) | |
| # First 1000000 results, returned as JSON from API / converted to Python list of | |
| # dictionaries by sodapy. There are rate limits if you don't authenticate, so if you might have to authenticate the client for more data. | |
| results = client.get("gkne-dk5s", limit=1000000) | |
| # Convert to pandas DataFrame | |
| results_df = pd.DataFrame.from_records(results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment