Ask
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News Sign UpSign In
Project: Testing 18.04
Views: 759
Embed | Download | Raw |
Kernel: Python 3 (Ubuntu Linux)

NOAA SDK in Python 3 (Ubuntu Linux)

https://github.com/paulokuong/noaa

from noaa_sdk import noaa n = noaa.NOAA()
fc = n.get_forecasts(postal_code="30005", country='US', hourly=True)[:48] fc[:2]
# convert short forecast wording to numeric level # only order matters: 0, 1, 2 def snow_number(s): if 'Heavy Snow' in s: ret = 2 elif 'Snow' in s: ret = 1 else: ret = 0 return ret
import pandas as pd df = pd.DataFrame(fc)[['startTime','temperature','shortForecast']] # fix types df['Time'] = pd.to_datetime(df['startTime']) df['Snowfall'] = df['shortForecast'].apply(snow_number) df = df.set_index('Time') df.head()
df[['temperature','Snowfall']].plot(subplots=True, sharex=True, figsize=(13,4.5), fontsize=8)