Skip to main content

basedosdados

basedosdados is a Python package that provides easy access to Brazil’s largest open data lake, hosted on Google BigQuery. It allows you to query, download, and analyze high-quality, ready-to-use public datasets with minimal setup.

Installation

Install from PyPI:

pip install basedosdados

Or using uv:

uv add basedosdados

Or with poetry:

poetry add basedosdados

Quickstart

Access a table

import basedosdados as bd

df = bd.read_table('br_ibge_pib', 'municipio', billing_project_id="<YOUR-PROJECT>")

On first use, you will be prompted to authenticate your Google Cloud project. See how to create a project here.

Run a SQL query

import basedosdados as bd

query = """
SELECT *
FROM `basedosdados.br_tse_eleicoes.bens_candidato`
WHERE ano = 2020
AND sigla_uf = 'TO'
"""

df = bd.read_sql(query, billing_project_id="<YOUR-PROJECT>")

Set global configuration

You can set your billing project globally to avoid passing it every time:

import basedosdados as bd

bd.config.billing_project_id = "<YOUR-PROJECT-ID>"

query = """
SELECT *
FROM `basedosdados.br_bd_diretorios_brasil.municipio`
"""

df = bd.read_sql(query=query)

Download query results to CSV

import basedosdados as bd

query = """
SELECT ano, id_municipio, pib
FROM `basedosdados.br_ibge_pib.municipio`
WHERE ano = 2010
"""

bd.download("pib_2010.csv", query=query, billing_project_id="<YOUR-PROJECT>")

Documentation

Advanced: Multiple Configurations

If you need to use multiple service accounts or configurations, you can manage them by renaming the config folder and setting bd.config.project_config_path:

import basedosdados as bd
bd.config.project_config_path = "/home/user/.bd_my_other_account"

Contributing

See our contribution guide for how to help improve this package.

License

MIT License. See LICENSE for details.


Part of the Base dos Dados project – universalizing access to quality data in Brazil.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

basedosdados-2.0.3.tar.gz (12.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

basedosdados-2.0.3-py3-none-any.whl (39.8 kB view details)

Uploaded Python 3

File details

Details for the file basedosdados-2.0.3.tar.gz.

File metadata

  • Download URL: basedosdados-2.0.3.tar.gz
  • Upload date:
  • Size: 12.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for basedosdados-2.0.3.tar.gz
Algorithm Hash digest
SHA256 5bbe6860e8c052547238af2ac57b96de57c8962e549078c68fb5019236075043
MD5 681229397466bd31e8890d497d017f83
BLAKE2b-256 c97b7cdd911f2782cfaa41696d2f79da0aae5e601cac521bdf4e6883aa57f2f3

See more details on using hashes here.

File details

Details for the file basedosdados-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: basedosdados-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 39.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for basedosdados-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f6f3375938fc6c57d0c1f320629075682157b92d7cd2da0796ce0d1fdbfd64af
MD5 6a36260002a8be6e2d6831f069ee8a0c
BLAKE2b-256 1065b35f3e82093022ea5a690e30312f9a1a00ae8e5cac0afafa135d28541b87

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.3

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page