Funções utilitárias para facilitar o uso do pandas
Project description
📦 bpandas
bpandas é uma coleção de helpers para deixar o uso do pandas mais simples e rápido.
Comece em segundos com tabela de frequências e gráfico de barras + linha (dois eixos Y) — limpo e profissional.
✨ O que vem pronto
bfrequencies(df, column, ...)→ distribuição de frequências (absoluta, relativa e acumuladas).blinebar(df, x, y_bar, y_line, ...)→ barras + linha com dois eixos Y (matplotlib puro, layout clean).
Ideal para dashboards rápidos, EDA e material didático.
📦 Instalação
PyPI:
pip install bpandas
Dev local (na raiz do projeto):
bash
Copiar
Editar
pip install -e .
Requisitos: Python 3.13. As versões das libs estão pinadas no pyproject.toml.
🚀 Comece em 30 segundos
python
Copiar
Editar
import pandas as pd
import bpandas as bp
# Exemplo simples
df = pd.DataFrame({"sexo": ["M","F","M","M","F", None]})
# 1) Tabela de frequências
freq = bp.bfrequencies(
df, "sexo",
include_na=True, # inclui ausentes
sort_by="index", # "index" ou "count"
ascending=True,
percent=True, # True = 0–100%; False = 0–1
decimals=2
)
print(freq.head())
# -> colunas: value, frequency, relative_frequency, cumulative_frequency, cumulative_relative_frequency
# 2) Gráfico: barras (freq absoluta) + linha (freq relativa acumulada)
bp.blinebar(
freq,
x="value",
y_bar="frequency",
y_line="cumulative_relative_frequency",
title="Distribuição por Sexo",
xlabel="Categorias",
ylabel_left="Frequência Absoluta",
ylabel_right="Frequência Acumulada (%)",
y2_is_percent=True, # formata eixo direito como %
rotate_xticks=0, # 0, 30, 45, 90...
# savepath="saida.png" # opcional: salva a figura
)
🧠 API (resumo)
bfrequencies(df, column_name, *, include_na=True, sort_by="index", ascending=True, percent=True, decimals=2) -> pd.DataFrame
Entrada: df (DataFrame), column_name (str).
Parâmetros úteis:
include_na (inclui/exclui ausentes) • sort_by ("index"/"count") • percent (0–100 vs 0–1) • decimals.
Saída: DataFrame com:
value, frequency, relative_frequency, cumulative_frequency, cumulative_relative_frequency.
blinebar(df, x, y_bar, y_line, *, title=None, xlabel=None, ylabel_left="Frequência Absoluta", ylabel_right="Frequência Acumulada (%)", y2_is_percent=True, figsize=(10,6), bar_width=0.65, color_bar=None, color_line=None, rotate_xticks=0, grid=True, savepath=None, show=True) -> (fig, ax, ax2)
Gráfico combinado (barras + linha) com 2 eixos Y.
y2_is_percent=True formata o eixo direito como % (assumindo 0–100).
Retorna fig, ax, ax2 para customizações posteriores.
🧪 Testes
bash
Copiar
Editar
python -m pytest -q
🛠 Roadmap
bsummary(df) — resumo rápido (shape, tipos, nulos, head).
bgroup(df, by, agg) — agrupamentos mais fáceis.
bexport(df, path) — salvar CSV/Excel/Parquet sem dor.
Sugestões são bem-vindas! Abra uma issue:
https://github.com/davidcloss/bpandas/issues
📄 Licença
MIT — veja LICENSE.
javascript
Copiar
Editar
se quiser, eu já crio um **CHANGELOG.md** básico (0.1.x) com as entradas de `bfrequencies`, `blinebar` e melhorias de README.
::contentReference[oaicite:0]{index=0}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bpandas-0.1.5.tar.gz
(5.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bpandas-0.1.5.tar.gz.
File metadata
- Download URL: bpandas-0.1.5.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
105efa560da07c0aa3271ec497760245d800164b56177f1931c743dae250e2c8
|
|
| MD5 |
bf1caee0d0c4ed10325cd3fa76b2138d
|
|
| BLAKE2b-256 |
047254ecc30b2c4705d34f4f85dddad057afecd07bf009690cdd90c309d023ce
|
File details
Details for the file bpandas-0.1.5-py3-none-any.whl.
File metadata
- Download URL: bpandas-0.1.5-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71f34f74c2aaac53441014f1844a6e1d9cfb43546660612cfcd42f3c22d76904
|
|
| MD5 |
a600b7f433d815e5c9dfb3f27e6fea18
|
|
| BLAKE2b-256 |
7775522d6165076d9ffd2832d8d502354d1c6c0d81185301c128ffce34f5a614
|