Skip to main content

Organize and facilitate access to Brazilian data through public tables on BigQuery.

Project description

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.

Project details


Release history Release notifications | RSS feed

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.1.0b1.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.1.0b1-py3-none-any.whl (40.0 kB view details)

Uploaded Python 3

File details

Details for the file basedosdados-2.1.0b1.tar.gz.

File metadata

  • Download URL: basedosdados-2.1.0b1.tar.gz
  • Upload date:
  • Size: 12.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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.1.0b1.tar.gz
Algorithm Hash digest
SHA256 f457412da21b55bfc0baad031bbca23b6f47f38365f6cc521af5b5396ee72fde
MD5 07bdbdc9f8cda2073f37013ce5a5eb96
BLAKE2b-256 6aa91e1069437b1fc02a7632c422cbbaeb2e2ae55d73401086544c011c7be3ba

See more details on using hashes here.

File details

Details for the file basedosdados-2.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: basedosdados-2.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 40.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 f018432f6d5cd764b155d9aeeb833f545a90241c430709fe309616bc20cfb92e
MD5 23827f9286713e1b3c5c4f250d4ff097
BLAKE2b-256 4ac825d960c299da5614bb2e2d122838cd77c69534f833c97754e0dc736f780c

See more details on using hashes here.

Supported by

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