Created
January 4, 2018 19:28
-
-
Save paulopperman/49b295bb5700f820eaecc73db0092701 to your computer and use it in GitHub Desktop.
Playing around with NOAA API: https://www.ncdc.noaa.gov/cdo-web/webservices/v2
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
import requests | |
import pandas as pd | |
# API documentation is at https://www.ncdc.noaa.gov/cdo-web/webservices/v2 | |
NOAA_API_TOKEN = '<from NOAA>' | |
headers = {'token':NOAA_API_TOKEN} | |
# get stations in Newport, RI | |
stations_response = requests.get('https://www.ncdc.noaa.gov/cdo-web/api/v2/stations?locationid=FIPS:44&sortfield=maxdate&sortorder=desc&limit=500',headers=headers) | |
stations = pd.io.json.json_normalize(stations_response.json()['results']) | |
stations = stations[stations.name.str.find("NEWPORT")==0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment