BCRA Query

PHOTO EMBED

Sat May 15 2021 13:49:32 GMT+0000 (Coordinated Universal Time)

Saved by @santiagogab #python

def bcra_query(variable='dolar_blue', url='https://api.estadisticasbcra.com/usd'):

    r = requests.get(url=url,
                                            headers={'Authorization':'BEARER '+bearer
                                
                            })
    r_dict = json.loads(r.text)

    df = pd.DataFrame(r_dict)


    df.rename(columns={'v': variable,
                                            'd':'fecha'},
                        inplace=True)

    #dolar_blue = df

    today = date.today()
    str(today)

    df.to_csv('dataset_'+variable, index=False)
content_copyCOPY