Branalysis
Biblioteca Python para coletar e analisar votações nominais do Congresso Nacional.
from branalysis.plenario import Camara
from datetime import date
from matplotlib import pyplot as plt
from statistics import mean
ANO = 2023
def calcula_idade(parlamentar):
return (date(ANO, 12, 31) - parlamentar.data_nascimento).days / 365
plenario = Camara(ANO)
# Organiza os partidos por idade média, criando tuplas (partido, idade média)
partido_idade_media = [
(partido, mean(calcula_idade(p) for p in parlamentares))
for partido, parlamentares in plenario.parlamentares_por_partido().items()
]
# Ordena por idade média crescente
partido_idade_media.sort(key=lambda x: x[1])
# Plota o gráfico de barras
barras = plt.bar(*zip(*partido_idade_media))
plt.bar_label(barras, fmt=lambda x: f'{x:.1f}', label_type='edge')
plt.ylabel('Idade média')
plt.xticks(rotation=-45, ha='left')
plt.show()
from branalysis import Camara, MatrizPolitica, Colorizador, CORES
from matplotlib.colors import ListedColormap
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
plenario = Camara(2023)
parlamentares = plenario.parlamentares()
# Cria a matriz de votos dos parlamentares
matriz = MatrizPolitica(parlamentares, plenario.votacoes()).de_parlamentares()
# Aplica a redução de dimensionalidade
modelo = PCA(n_components=2).fit_transform(matriz)
# Cria um colorizador, que mapeia cores para cada partido
colorizador = Colorizador(fallback='MAIS DE UM')
cor_por_parlamentar = [colorizador[p.partidos()] for p in parlamentares]
# Plota o mapa ideológico
grafico = plt.scatter(modelo[:, 0], modelo[:, 1], cmap=ListedColormap(CORES), c=cor_por_parlamentar)
texto_legenda, cores = colorizador.textos_e_cores()
cores_legenda = grafico.legend_elements(num=cores)[0]
plt.legend(cores_legenda, texto_legenda)
plt.show()
Metadata
Release files for branalysis 1.0.12
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 |
|---|---|---|---|---|
| branalysis-1.0.12.tar.gz | 13.2 kB | Without provenance | Details for branalysis-1.0.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| branalysis-1.0.12-py3-none-any.whl | Python 3 | none | any | Details for branalysis-1.0.12-py3-none-any.whl |
Total release size: 29.6 kB
Release files / branalysis-1.0.12.tar.gz
| Download URL | branalysis-1.0.12.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bb849ef43a64513aaa3d62da45df40fd7b1b92188e47a99373648c01cdef7ec
|
|
BLAKE2b-256 checksum How to use checksums |
e7394bb373dcce7fb0ef93f1e8837c3edffbbb08687fa10a02b6bde54e9c66b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / branalysis-1.0.12-py3-none-any.whl
| Download URL | branalysis-1.0.12-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
05d250135bc9476c9b4160fc5946b636b584b6ea1ff558664d3a9c20c01c2780
|
|
BLAKE2b-256 checksum How to use checksums |
d033686449532d6cb50310a1c347e9842c9546176a190ee1d8b0d90d8f2d722d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Security for branalysis 1.0.12
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.