Source code for seriesbr.helpers.lists
from pandas import DataFrame
from .request import get_json
from .utils import clean_json, do_search
# IBGE
[docs]def list_regions_helper(region, search, searches):
"""
Auxiliary function to list information
about a given location in IBGE's database.
Parameters
----------
region : str
Kind of region to list (macroregion, state etc.)
search : list
Strings to search in names column.
searches : dict
Strings to search in other columns.
Returns
-------
pandas.DataFrame
A DataFrame with the regions, filtered if specified.
"""
url = f"https://servicodados.ibge.gov.br/api/v1/localidades/{region}"
json = get_json(url)
df = clean_json(json)
if search or searches:
return do_search(df, search, searches)
return df
# IPEA