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.
Metadata
Release files for basedosdados 2.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| basedosdados-2.0.3.tar.gz | 12.2 MB | Without provenance | Details for basedosdados-2.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| basedosdados-2.0.3-py3-none-any.whl | Python 3 | none | any | Details for basedosdados-2.0.3-py3-none-any.whl |
Total release size: 12.2 MB
Release files / basedosdados-2.0.3.tar.gz
| Download URL | basedosdados-2.0.3.tar.gz |
|---|---|
| Size | 12.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5bbe6860e8c052547238af2ac57b96de57c8962e549078c68fb5019236075043
|
|
BLAKE2b-256 checksum How to use checksums |
c97b7cdd911f2782cfaa41696d2f79da0aae5e601cac521bdf4e6883aa57f2f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / basedosdados-2.0.3-py3-none-any.whl
| Download URL | basedosdados-2.0.3-py3-none-any.whl |
|---|---|
| Size | 39.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6f3375938fc6c57d0c1f320629075682157b92d7cd2da0796ce0d1fdbfd64af
|
|
BLAKE2b-256 checksum How to use checksums |
1065b35f3e82093022ea5a690e30312f9a1a00ae8e5cac0afafa135d28541b87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for basedosdados 2.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.