1

I am trying to pull from FRED's API using a list of unique identifiers:

quarterly_list = ['GDP', 'M1V', 'M2V']

for i in quarterly_list:
  *i want the value stored in i to be the name of the dataset* = fredpy.get_series(
    seriesID = *i want the value stored in i to be the series ID*,
    start = '2005-01-01',
    end = '9999-12-31',
    units = 'lin')

With each loop should create a new data frame titled the value in i during that loop and the seriesID should recognize i as the value to be pulled from FRED's API

Thank you!

Red
  • 21
  • 3

1 Answers1

0

You can use a dictionary:

quarterly_list = ['GDP', 'M1V', 'M2V']
data = {}

for i in quarterly_list:
    data[i] = fredpy.get_series(seriesId = i, start = '2005-01-01', end = '9999-12-31', units = 'lin')

To access data from the dictionary, use this syntax:

data['GDP'] # This gives the data that had seriesID 'GDP'
data['M1V']
data['M2V']
linger1109
  • 500
  • 2
  • 11