2
I created a function to collect data from the Central Bank by separating by variables that I want to work. Now I wanted to create a data frame that had all this information, but I’m not getting it, if anyone can help me thank you.
def consulta_bc(codigo_bc):
url = 'http://api.bcb.gov.br/dados/serie/bcdata.sgs.{}/dados?formato=json'.format(codigo_bc)
df = pd.read_json(url)
df['data'] = pd.to_datetime(df['data'], dayfirst = True)
df.set_index('data', inplace = True)
return df.loc['2015-01-01' : '2020-09-01']
pib = consulta_bc(4380)
tx_selic = consulta_bc(4390)
desemprego = consulta_bc(24369)
m1 = consulta_bc(27791)
igpm = consulta_bc(189)
data = [[pib, tx_selic, desemprego, m1, igpm]]
index = pd.date_range(start = '2015-01-01', end = '2020-09-01', freq = "M")
df = pd.DataFrame(data, columns = [['Pib', 'Selic', 'Desemprego', 'M1', 'IGP-M']], index = index)
df
Describing the general problem you will get only a general answer. Example: "How to build a house?" , "Use blocks and cement, build solid walls". Instead ask something specific and responsive in a useful way: "How to lift a wall using this type of block with such a slope and such height safely?" , answer: "Position the blocks in such format, run this block placement algorithm, do not use this tool because there is such a risk, here is an example running from a wall ready for you to see how it does [link]". See? Too many wide questions don’t help.
– Lucas