Hi there,
When I use this code in the excel version:
import ssl
print(ssl.OPENSSL_VERSION)
It gives following error:
Traceback (most recent call last):
File “‘DATA’!B18”, line 1, in
import ssl
ModuleNotFoundError: No module named ‘ssl’
My question is this to do with Anaconda Toolbox not able to request data from websites like FRED? I have installed “requests” and fredapi libraries but when requesting FRED data, I just get errors.
For instance when requesting
import requests
import pandas as pd
api_key = “Key here”
series_list = [“WSHOMCB”, “WRESBAL”, “RRPONTSYD”]
frames =
for series_id in series_list:
url = f"https://api.stlouisfed.org/fred/series/observations?series_id={series_id}&api_key={api_key}&file_type=json"
response = requests.get(url)
obs = response.json()[‘observations’]
df = pd.DataFrame(obs)[[‘date’, ‘value’]]
df[‘value’] = pd.to_numeric(df[‘value’], errors=‘coerce’)
df[‘date’] = pd.to_datetime(df[‘date’])
df[‘SeriesID’] = series_id
frames.append(df)
final = pd.concat(frames, ignore_index=True)
pivoted = final.pivot(index=“date”, columns=“SeriesID”, values=“value”)
pivoted.tail()
This comes out with series of errors in the anaconda toolbox, but works fine in jupiter notebook.
Thank you for your time.