Análise do Eleitorado Brasileiro

In [1]:
# importando as bibliotecas
import pandas as pd
In [5]:
# Carregando o arquivo csv
df = pd.read_csv('eleitorado_municipio_2018.csv', encoding = "latin1", sep = ";")

df.head()
Out[5]:
NR_ANO_ELEICAO CD_PAIS NM_PAIS SG_REGIAO NM_REGIAO SG_UF NM_UF CD_MUNICIPIO NM_MUNICIPIO QTD_ELEITORES ... QTD_ELEITORES_90A94 QTD_ELEITORES_95A99 QTD_ELEITORES_MAIORIGUAL100 QTD_ELEITORES_IDADEINVALIDO QTD_ELEITORES_IDADENAOSEAPLICA QTD_ELEITORES_IDADENAOINFORMADA QTD_ELEITORES_COMBIOMETRIA QTD_ELEITORES_SEMBIOMETRIA QTD_ELEITORES_DEFICIENTE QUANTITATIVO_NOMESOCIAL
0 2018 1 Brasil N Norte AC Acre 1120 ACRELÂNDIA 8809 ... 8 2 0 0 0 0 8784 25 35 0
1 2018 1 Brasil N Norte AC Acre 1570 ASSIS BRASIL 5726 ... 14 4 0 0 0 0 5712 14 13 0
2 2018 1 Brasil N Norte AC Acre 1058 BRASILÉIA 16041 ... 14 4 4 0 0 0 15905 136 92 0
3 2018 1 Brasil N Norte AC Acre 1007 BUJARI 8683 ... 11 2 0 0 0 0 8665 18 18 0
4 2018 1 Brasil N Norte AC Acre 1015 CAPIXABA 6832 ... 5 1 0 0 0 0 6820 12 78 0

5 rows × 43 columns

In [8]:
df.describe()
Out[8]:
NR_ANO_ELEICAO CD_PAIS CD_MUNICIPIO QTD_ELEITORES QTD_ELEITORES_FEMININO QTD_ELEITORES_MASCULINO QTD_ELEITORES_NAOINFORMADO QTD_ELEITORES_MENOR16 QTD_ELEITORES_16 QTD_ELEITORES_17 ... QTD_ELEITORES_90A94 QTD_ELEITORES_95A99 QTD_ELEITORES_MAIORIGUAL100 QTD_ELEITORES_IDADEINVALIDO QTD_ELEITORES_IDADENAOSEAPLICA QTD_ELEITORES_IDADENAOINFORMADA QTD_ELEITORES_COMBIOMETRIA QTD_ELEITORES_SEMBIOMETRIA QTD_ELEITORES_DEFICIENTE QUANTITATIVO_NOMESOCIAL
count 5741.0 5741.000000 5741.000000 5.741000e+03 5.741000e+03 5.741000e+03 5741.000000 5741.0 5741.000000 5741.000000 ... 5741.000000 5741.000000 5741.000000 5741.000000 5741.0 5741.0 5.741000e+03 5.741000e+03 5741.000000 5741.000000
mean 2018.0 1.029786 51017.218429 2.565864e+04 1.347150e+04 1.217610e+04 11.043546 0.0 70.315799 173.651629 ... 120.027521 47.456366 6.801777 0.506880 0.0 0.0 1.521740e+04 1.044124e+04 163.844278 1.093886
std 0.0 0.170011 29219.828969 1.569453e+05 8.489634e+04 7.192142e+04 154.775232 0.0 188.195768 642.578409 ... 1545.919431 668.866576 58.426833 2.093668 0.0 0.0 8.591800e+04 9.066753e+04 2004.691627 9.316431
min 2018.0 1.000000 19.000000 1.000000e+00 0.000000e+00 0.000000e+00 0.000000 0.0 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.0 0.0 0.000000e+00 0.000000e+00 0.000000 0.000000
25% 2018.0 1.000000 25119.000000 4.264000e+03 2.102000e+03 2.153000e+03 0.000000 0.0 13.000000 32.000000 ... 8.000000 1.000000 0.000000 0.000000 0.0 0.0 1.593000e+03 8.000000e+00 9.000000 0.000000
50% 2018.0 1.000000 49794.000000 8.354000e+03 4.206000e+03 4.129000e+03 0.000000 0.0 35.000000 76.000000 ... 22.000000 6.000000 1.000000 0.000000 0.0 0.0 4.326000e+03 4.910000e+02 24.000000 0.000000
75% 2018.0 1.000000 78611.000000 1.772700e+04 9.067000e+03 8.634000e+03 3.000000 0.0 77.000000 166.000000 ... 70.000000 25.000000 5.000000 1.000000 0.0 0.0 1.060000e+04 7.314000e+03 66.000000 0.000000
max 2018.0 2.000000 99430.000000 9.052724e+06 4.880298e+06 4.162595e+06 9831.000000 0.0 8297.000000 33012.000000 ... 81644.000000 36069.000000 3439.000000 96.000000 0.0 0.0 4.346933e+06 4.705791e+06 138884.000000 551.000000

8 rows × 37 columns

In [9]:
df.head().T
Out[9]:
0 1 2 3 4
NR_ANO_ELEICAO 2018 2018 2018 2018 2018
CD_PAIS 1 1 1 1 1
NM_PAIS Brasil Brasil Brasil Brasil Brasil
SG_REGIAO N N N N N
NM_REGIAO Norte Norte Norte Norte Norte
SG_UF AC AC AC AC AC
NM_UF Acre Acre Acre Acre Acre
CD_MUNICIPIO 1120 1570 1058 1007 1015
NM_MUNICIPIO ACRELÂNDIA ASSIS BRASIL BRASILÉIA BUJARI CAPIXABA
QTD_ELEITORES 8809 5726 16041 8683 6832
QTD_ELEITORES_FEMININO 4322 2871 8247 4287 3324
QTD_ELEITORES_MASCULINO 4487 2855 7794 4396 3508
QTD_ELEITORES_NAOINFORMADO 0 0 0 0 0
QTD_ELEITORES_MENOR16 0 0 0 0 0
QTD_ELEITORES_16 47 42 107 84 75
QTD_ELEITORES_17 113 73 249 126 139
QTD_ELEITORES_18 229 133 358 204 193
QTD_ELEITORES_19 225 129 435 248 240
QTD_ELEITORES_20 232 163 424 268 210
QTD_ELEITORES_21A24 890 649 1654 925 721
QTD_ELEITORES_25A29 1033 763 1976 988 757
QTD_ELEITORES_30A34 973 704 1759 983 681
QTD_ELEITORES_35A39 1072 675 1830 1024 702
QTD_ELEITORES_40A44 831 573 1568 895 654
QTD_ELEITORES_45A49 732 434 1411 700 601
QTD_ELEITORES_50A54 608 351 1216 581 541
QTD_ELEITORES_55A59 602 282 899 471 429
QTD_ELEITORES_60A64 419 239 767 448 355
QTD_ELEITORES_65A69 349 194 591 328 246
QTD_ELEITORES_70A74 217 141 375 190 139
QTD_ELEITORES_75A79 126 87 216 136 96
QTD_ELEITORES_80A84 74 49 127 49 27
QTD_ELEITORES_85A89 27 27 57 22 20
QTD_ELEITORES_90A94 8 14 14 11 5
QTD_ELEITORES_95A99 2 4 4 2 1
QTD_ELEITORES_MAIORIGUAL100 0 0 4 0 0
QTD_ELEITORES_IDADEINVALIDO 0 0 0 0 0
QTD_ELEITORES_IDADENAOSEAPLICA 0 0 0 0 0
QTD_ELEITORES_IDADENAOINFORMADA 0 0 0 0 0
QTD_ELEITORES_COMBIOMETRIA 8784 5712 15905 8665 6820
QTD_ELEITORES_SEMBIOMETRIA 25 14 136 18 12
QTD_ELEITORES_DEFICIENTE 35 13 92 18 78
QUANTITATIVO_NOMESOCIAL 0 0 0 0 0
In [10]:
# Tipos de quantidades
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5741 entries, 0 to 5740
Data columns (total 43 columns):
NR_ANO_ELEICAO                     5741 non-null int64
CD_PAIS                            5741 non-null int64
NM_PAIS                            5741 non-null object
SG_REGIAO                          5741 non-null object
NM_REGIAO                          5741 non-null object
SG_UF                              5741 non-null object
NM_UF                              5741 non-null object
CD_MUNICIPIO                       5741 non-null int64
NM_MUNICIPIO                       5741 non-null object
QTD_ELEITORES                      5741 non-null int64
QTD_ELEITORES_FEMININO             5741 non-null int64
QTD_ELEITORES_MASCULINO            5741 non-null int64
QTD_ELEITORES_NAOINFORMADO         5741 non-null int64
QTD_ELEITORES_MENOR16              5741 non-null int64
QTD_ELEITORES_16                   5741 non-null int64
QTD_ELEITORES_17                   5741 non-null int64
QTD_ELEITORES_18                   5741 non-null int64
QTD_ELEITORES_19                   5741 non-null int64
QTD_ELEITORES_20                   5741 non-null int64
QTD_ELEITORES_21A24                5741 non-null int64
QTD_ELEITORES_25A29                5741 non-null int64
QTD_ELEITORES_30A34                5741 non-null int64
QTD_ELEITORES_35A39                5741 non-null int64
QTD_ELEITORES_40A44                5741 non-null int64
QTD_ELEITORES_45A49                5741 non-null int64
QTD_ELEITORES_50A54                5741 non-null int64
QTD_ELEITORES_55A59                5741 non-null int64
QTD_ELEITORES_60A64                5741 non-null int64
QTD_ELEITORES_65A69                5741 non-null int64
QTD_ELEITORES_70A74                5741 non-null int64
QTD_ELEITORES_75A79                5741 non-null int64
QTD_ELEITORES_80A84                5741 non-null int64
QTD_ELEITORES_85A89                5741 non-null int64
QTD_ELEITORES_90A94                5741 non-null int64
QTD_ELEITORES_95A99                5741 non-null int64
QTD_ELEITORES_MAIORIGUAL100        5741 non-null int64
QTD_ELEITORES_IDADEINVALIDO        5741 non-null int64
QTD_ELEITORES_IDADENAOSEAPLICA     5741 non-null int64
QTD_ELEITORES_IDADENAOINFORMADA    5741 non-null int64
QTD_ELEITORES_COMBIOMETRIA         5741 non-null int64
QTD_ELEITORES_SEMBIOMETRIA         5741 non-null int64
QTD_ELEITORES_DEFICIENTE           5741 non-null int64
QUANTITATIVO_NOMESOCIAL            5741 non-null int64
dtypes: int64(37), object(6)
memory usage: 1.8+ MB
In [12]:
#  As 5 cidades com maior número de eleitores deficientes
df.nlargest(5, 'QTD_ELEITORES_DEFICIENTE')
Out[12]:
NR_ANO_ELEICAO CD_PAIS NM_PAIS SG_REGIAO NM_REGIAO SG_UF NM_UF CD_MUNICIPIO NM_MUNICIPIO QTD_ELEITORES ... QTD_ELEITORES_90A94 QTD_ELEITORES_95A99 QTD_ELEITORES_MAIORIGUAL100 QTD_ELEITORES_IDADEINVALIDO QTD_ELEITORES_IDADENAOSEAPLICA QTD_ELEITORES_IDADENAOINFORMADA QTD_ELEITORES_COMBIOMETRIA QTD_ELEITORES_SEMBIOMETRIA QTD_ELEITORES_DEFICIENTE QUANTITATIVO_NOMESOCIAL
5358 2018 1 Brasil SE Sudeste SP São Paulo 71072 SÃO PAULO 9052724 ... 77321 33110 3439 96 0 0 4346933 4705791 138884 551
3660 2018 1 Brasil SE Sudeste RJ Rio de Janeiro 60011 RIO DE JANEIRO 4891885 ... 81644 36069 2219 64 0 0 691875 4200010 23228 203
4990 2018 1 Brasil SE Sudeste SP São Paulo 64777 GUARULHOS 814342 ... 117 13 4 7 0 0 813706 636 22266 82
535 2018 1 Brasil NE Nordeste BA Bahia 38490 SALVADOR 1827436 ... 939 164 34 7 0 0 1826047 1389 19305 122
4010 2018 1 Brasil S Sul RS Rio Grande do Sul 85995 CAXIAS DO SUL 322901 ... 336 46 2 0 0 0 322336 565 18360 14

5 rows × 43 columns

In [14]:
print('Eleitoras:', df['QTD_ELEITORES_FEMININO'].sum())
print('Eleitores:', df['QTD_ELEITORES_MASCULINO'].sum())
print('Eleitores com sexo não informado:', df['QTD_ELEITORES_NAOINFORMADO'].sum())
Eleitoras: 77339897
Eleitores: 69902977
Eleitores com sexo não informado: 63401
In [17]:
# Criar variáveis para calcular o percentual
tot_eleitores = df['QTD_ELEITORES'].sum()
tot_fem  = df['QTD_ELEITORES_FEMININO'].sum()
tot_mas = df['QTD_ELEITORES_MASCULINO'].sum()
tot_outros = df['QTD_ELEITORES_NAOINFORMADO'].sum()
In [20]:
porc_fem = (tot_fem / tot_eleitores * 100).round(2)
porc_mas = (tot_mas / tot_eleitores * 100).round(2)
porc_outros = (tot_outros / tot_eleitores * 100).round(2)
In [21]:
print('Porcentagem de eleitoras:', porc_fem)
print('Porcentagem de eleitores:', porc_mas)
print('Porcentagem de eleitores com sexo não informado:', porc_outros)
Porcentagem de eleitoras: 52.5
Porcentagem de eleitores: 47.45
Porcentagem de eleitores com sexo não informado: 0.04
In [24]:
# Quantas municipios com mais homens que mulheres?
df[df['QTD_ELEITORES_MASCULINO'] > df['QTD_ELEITORES_FEMININO']].count()
Out[24]:
NR_ANO_ELEICAO                     2279
CD_PAIS                            2279
NM_PAIS                            2279
SG_REGIAO                          2279
NM_REGIAO                          2279
SG_UF                              2279
NM_UF                              2279
CD_MUNICIPIO                       2279
NM_MUNICIPIO                       2279
QTD_ELEITORES                      2279
QTD_ELEITORES_FEMININO             2279
QTD_ELEITORES_MASCULINO            2279
QTD_ELEITORES_NAOINFORMADO         2279
QTD_ELEITORES_MENOR16              2279
QTD_ELEITORES_16                   2279
QTD_ELEITORES_17                   2279
QTD_ELEITORES_18                   2279
QTD_ELEITORES_19                   2279
QTD_ELEITORES_20                   2279
QTD_ELEITORES_21A24                2279
QTD_ELEITORES_25A29                2279
QTD_ELEITORES_30A34                2279
QTD_ELEITORES_35A39                2279
QTD_ELEITORES_40A44                2279
QTD_ELEITORES_45A49                2279
QTD_ELEITORES_50A54                2279
QTD_ELEITORES_55A59                2279
QTD_ELEITORES_60A64                2279
QTD_ELEITORES_65A69                2279
QTD_ELEITORES_70A74                2279
QTD_ELEITORES_75A79                2279
QTD_ELEITORES_80A84                2279
QTD_ELEITORES_85A89                2279
QTD_ELEITORES_90A94                2279
QTD_ELEITORES_95A99                2279
QTD_ELEITORES_MAIORIGUAL100        2279
QTD_ELEITORES_IDADEINVALIDO        2279
QTD_ELEITORES_IDADENAOSEAPLICA     2279
QTD_ELEITORES_IDADENAOINFORMADA    2279
QTD_ELEITORES_COMBIOMETRIA         2279
QTD_ELEITORES_SEMBIOMETRIA         2279
QTD_ELEITORES_DEFICIENTE           2279
QUANTITATIVO_NOMESOCIAL            2279
dtype: int64
In [25]:
# Criando uma nova coluna para indicar a relação fem/masc
df['RELACAO_FM'] = df['QTD_ELEITORES_FEMININO'] / df['QTD_ELEITORES_MASCULINO']
In [27]:
df['RELACAO_FM'].describe()
Out[27]:
count    5741.000000
mean             inf
std              NaN
min         0.000000
25%         0.967283
50%         1.021461
75%         1.073350
max              inf
Name: RELACAO_FM, dtype: float64
In [29]:
# Quais são os municipios com maior relação f/m
df.nlargest(5, 'RELACAO_FM').T
Out[29]:
5581 5613 5652 5658 5653
NR_ANO_ELEICAO 2018 2018 2018 2018 2018
CD_PAIS 2 2 2 2 2
NM_PAIS Exterior Exterior Exterior Exterior Exterior
SG_REGIAO E E E E E
NM_REGIAO Exterior Exterior Exterior Exterior Exterior
SG_UF ZZ ZZ ZZ ZZ ZZ
NM_UF Exterior Exterior Exterior Exterior Exterior
CD_MUNICIPIO 99350 38920 99422 29963 29939
NM_MUNICIPIO BAMAKO COTONOU LETHEM LOMÉ LIBREVILLE
QTD_ELEITORES 1 2 1 3 21
QTD_ELEITORES_FEMININO 1 2 1 3 19
QTD_ELEITORES_MASCULINO 0 0 0 0 2
QTD_ELEITORES_NAOINFORMADO 0 0 0 0 0
QTD_ELEITORES_MENOR16 0 0 0 0 0
QTD_ELEITORES_16 0 0 0 0 0
QTD_ELEITORES_17 0 0 0 0 0
QTD_ELEITORES_18 0 0 0 0 0
QTD_ELEITORES_19 0 0 0 0 0
QTD_ELEITORES_20 0 0 0 0 0
QTD_ELEITORES_21A24 0 0 0 0 0
QTD_ELEITORES_25A29 0 0 0 0 3
QTD_ELEITORES_30A34 0 0 0 0 1
QTD_ELEITORES_35A39 0 0 0 2 2
QTD_ELEITORES_40A44 1 0 0 1 2
QTD_ELEITORES_45A49 0 0 1 0 0
QTD_ELEITORES_50A54 0 0 0 0 8
QTD_ELEITORES_55A59 0 2 0 0 0
QTD_ELEITORES_60A64 0 0 0 0 3
QTD_ELEITORES_65A69 0 0 0 0 1
QTD_ELEITORES_70A74 0 0 0 0 1
QTD_ELEITORES_75A79 0 0 0 0 0
QTD_ELEITORES_80A84 0 0 0 0 0
QTD_ELEITORES_85A89 0 0 0 0 0
QTD_ELEITORES_90A94 0 0 0 0 0
QTD_ELEITORES_95A99 0 0 0 0 0
QTD_ELEITORES_MAIORIGUAL100 0 0 0 0 0
QTD_ELEITORES_IDADEINVALIDO 0 0 0 0 0
QTD_ELEITORES_IDADENAOSEAPLICA 0 0 0 0 0
QTD_ELEITORES_IDADENAOINFORMADA 0 0 0 0 0
QTD_ELEITORES_COMBIOMETRIA 0 0 1 0 0
QTD_ELEITORES_SEMBIOMETRIA 1 2 0 3 21
QTD_ELEITORES_DEFICIENTE 0 0 0 0 0
QUANTITATIVO_NOMESOCIAL 0 0 0 0 0
RELACAO_FM inf inf inf inf 9.5
In [30]:
# Quais os municipios com a menor relação f/m?
df.nsmallest(5, 'RELACAO_FM')
Out[30]:
NR_ANO_ELEICAO CD_PAIS NM_PAIS SG_REGIAO NM_REGIAO SG_UF NM_UF CD_MUNICIPIO NM_MUNICIPIO QTD_ELEITORES ... QTD_ELEITORES_95A99 QTD_ELEITORES_MAIORIGUAL100 QTD_ELEITORES_IDADEINVALIDO QTD_ELEITORES_IDADENAOSEAPLICA QTD_ELEITORES_IDADENAOINFORMADA QTD_ELEITORES_COMBIOMETRIA QTD_ELEITORES_SEMBIOMETRIA QTD_ELEITORES_DEFICIENTE QUANTITATIVO_NOMESOCIAL RELACAO_FM
5592 2018 2 Exterior E Exterior ZZ Exterior 39187 BRAZZAVILLE 3 ... 0 0 0 0 0 0 3 0 0 0.000000
5610 2018 2 Exterior E Exterior ZZ Exterior 38903 CONACRI 2 ... 0 0 0 0 0 0 2 0 0 0.000000
5625 2018 2 Exterior E Exterior ZZ Exterior 99406 FREETOWN 2 ... 0 0 0 0 0 0 2 0 0 0.000000
5719 2018 2 Exterior E Exterior ZZ Exterior 30546 SÓFIA 16 ... 0 0 0 0 0 0 16 0 0 0.230769
5639 2018 2 Exterior E Exterior ZZ Exterior 38989 IEREVAN-ARME 12 ... 0 0 0 0 0 0 12 0 0 0.333333

5 rows × 44 columns

In [33]:
# Criando um novo dataframe só com municipios do Brasil
df_brasil = df[df['CD_PAIS'] == 1].copy()
In [34]:
df_brasil.head()
Out[34]:
NR_ANO_ELEICAO CD_PAIS NM_PAIS SG_REGIAO NM_REGIAO SG_UF NM_UF CD_MUNICIPIO NM_MUNICIPIO QTD_ELEITORES ... QTD_ELEITORES_95A99 QTD_ELEITORES_MAIORIGUAL100 QTD_ELEITORES_IDADEINVALIDO QTD_ELEITORES_IDADENAOSEAPLICA QTD_ELEITORES_IDADENAOINFORMADA QTD_ELEITORES_COMBIOMETRIA QTD_ELEITORES_SEMBIOMETRIA QTD_ELEITORES_DEFICIENTE QUANTITATIVO_NOMESOCIAL RELACAO_FM
0 2018 1 Brasil N Norte AC Acre 1120 ACRELÂNDIA 8809 ... 2 0 0 0 0 8784 25 35 0 0.963227
1 2018 1 Brasil N Norte AC Acre 1570 ASSIS BRASIL 5726 ... 4 0 0 0 0 5712 14 13 0 1.005604
2 2018 1 Brasil N Norte AC Acre 1058 BRASILÉIA 16041 ... 4 4 0 0 0 15905 136 92 0 1.058122
3 2018 1 Brasil N Norte AC Acre 1007 BUJARI 8683 ... 2 0 0 0 0 8665 18 18 0 0.975205
4 2018 1 Brasil N Norte AC Acre 1015 CAPIXABA 6832 ... 1 0 0 0 0 6820 12 78 0 0.947548

5 rows × 44 columns

In [36]:
# Quais os municipios com a menor relação f/m?
df_brasil.nsmallest(5, 'RELACAO_FM')
Out[36]:
NR_ANO_ELEICAO CD_PAIS NM_PAIS SG_REGIAO NM_REGIAO SG_UF NM_UF CD_MUNICIPIO NM_MUNICIPIO QTD_ELEITORES ... QTD_ELEITORES_95A99 QTD_ELEITORES_MAIORIGUAL100 QTD_ELEITORES_IDADEINVALIDO QTD_ELEITORES_IDADENAOSEAPLICA QTD_ELEITORES_IDADENAOINFORMADA QTD_ELEITORES_COMBIOMETRIA QTD_ELEITORES_SEMBIOMETRIA QTD_ELEITORES_DEFICIENTE QUANTITATIVO_NOMESOCIAL RELACAO_FM
2389 2018 1 Brasil CO Centro-Oeste MT Mato Grosso 90980 SANTA CRUZ DO XINGU 1571 ... 0 0 0 0 0 40 1531 1 0 0.755307
1237 2018 1 Brasil NE Nordeste MA Maranhão 7900 MARAJÁ DO SENA 6416 ... 4 0 1 0 0 2141 4275 4 0 0.769379
2362 2018 1 Brasil CO Centro-Oeste MT Mato Grosso 90948 NOVO SANTO ANTÔNIO 1701 ... 8 1 0 0 0 49 1652 0 0 0.781152
2396 2018 1 Brasil CO Centro-Oeste MT Mato Grosso 90921 SERRA NOVA DOURADA 1379 ... 0 0 0 0 0 1379 0 4 0 0.788586
2361 2018 1 Brasil CO Centro-Oeste MT Mato Grosso 90808 NOVO MUNDO 5064 ... 5 0 1 0 0 48 5016 2 0 0.793201

5 rows × 44 columns

In [38]:
# Quais são os municipios com maior relação f/m
df_brasil.nlargest(5, 'RELACAO_FM').T
Out[38]:
3653 535 2894 373 329
NR_ANO_ELEICAO 2018 2018 2018 2018 2018
CD_PAIS 1 1 1 1 1
NM_PAIS Brasil Brasil Brasil Brasil Brasil
SG_REGIAO SE NE NE NE NE
NM_REGIAO Sudeste Nordeste Nordeste Nordeste Nordeste
SG_UF RJ BA PE BA BA
NM_UF Rio de Janeiro Bahia Pernambuco Bahia Bahia
CD_MUNICIPIO 58122 38490 24910 35939 35157
NM_MUNICIPIO QUEIMADOS SALVADOR OLINDA IRECÊ FEIRA DE SANTANA
QTD_ELEITORES 72971 1827436 276081 44082 384050
QTD_ELEITORES_FEMININO 41542 1022159 153719 24526 213559
QTD_ELEITORES_MASCULINO 31429 805276 122362 19556 170490
QTD_ELEITORES_NAOINFORMADO 0 1 0 0 1
QTD_ELEITORES_MENOR16 0 0 0 0 0
QTD_ELEITORES_16 180 1827 296 210 443
QTD_ELEITORES_17 729 8991 1176 546 2316
QTD_ELEITORES_18 1664 26040 3844 929 6175
QTD_ELEITORES_19 2020 34122 5136 909 7887
QTD_ELEITORES_20 1826 36043 5821 1043 8187
QTD_ELEITORES_21A24 6738 148382 23565 3875 34220
QTD_ELEITORES_25A29 7343 175583 28145 4580 40784
QTD_ELEITORES_30A34 6910 211822 28887 5149 46663
QTD_ELEITORES_35A39 7223 233774 31088 5369 48279
QTD_ELEITORES_40A44 7054 197952 28741 4760 41023
QTD_ELEITORES_45A49 6638 173908 28008 3998 35205
QTD_ELEITORES_50A54 6308 163238 25703 3572 31790
QTD_ELEITORES_55A59 5744 141334 22248 2731 25124
QTD_ELEITORES_60A64 5057 113029 17203 2269 20199
QTD_ELEITORES_65A69 3831 83872 13240 1664 15268
QTD_ELEITORES_70A74 1975 43131 8019 1194 10076
QTD_ELEITORES_75A79 1043 20619 3107 733 5911
QTD_ELEITORES_80A84 455 9172 1319 353 2806
QTD_ELEITORES_85A89 178 3453 404 149 1253
QTD_ELEITORES_90A94 46 939 107 34 356
QTD_ELEITORES_95A99 6 164 11 8 71
QTD_ELEITORES_MAIORIGUAL100 3 34 3 6 9
QTD_ELEITORES_IDADEINVALIDO 0 7 10 1 5
QTD_ELEITORES_IDADENAOSEAPLICA 0 0 0 0 0
QTD_ELEITORES_IDADENAOINFORMADA 0 0 0 0 0
QTD_ELEITORES_COMBIOMETRIA 72927 1826047 275800 44058 383530
QTD_ELEITORES_SEMBIOMETRIA 44 1389 281 24 520
QTD_ELEITORES_DEFICIENTE 942 19305 1756 117 2043
QUANTITATIVO_NOMESOCIAL 6 122 12 1 4
RELACAO_FM 1.32177 1.26933 1.25626 1.25414 1.25262
In [43]:
%matplotlib inline
# plotando um gráfico de distribuição da relação f/m
df_brasil['RELACAO_FM'].hist(bins = 100)
Out[43]:
<matplotlib.axes._subplots.AxesSubplot at 0xe879410>
In [44]:
# importando as bibliotecas gráficas
import seaborn as sns
import matplotlib.pyplot as plt
In [50]:
# Plotar a distribuição da relação f/m
sns.distplot(df_brasil['RELACAO_FM'], bins = 100, color = 'red', kde = False)

# Alterando o gráfico
plt.title('Relação Eleitoras/Eleitores', fontsize = 18)
plt.xlabel('Eleitoras/Eleitores', fontsize = 14)
plt.ylabel('Frequência', fontsize = 14)
plt.axvline(1.0, color='black', linestyle='--')
Out[50]:
<matplotlib.lines.Line2D at 0x10478150>
In [53]:
# verificar a distribuição f/m, mas mostrando os pontos (municipios)
sns.swarmplot(data = df_brasil, x = 'NM_REGIAO', y = 'RELACAO_FM')

# Alterando
plt.axhline(1.0, color = 'black', linestyle = '--')
Out[53]:
<matplotlib.lines.Line2D at 0x128e4dd0>
In [56]:
# plotando a quantidade total de eleitores por faixa etária

# primeiro - listar as colunas de interesse
lista = ['QTD_ELEITORES_16', 'QTD_ELEITORES_17', 'QTD_ELEITORES_18', 'QTD_ELEITORES_19', 'QTD_ELEITORES_20']

tot_idade = df[lista]. sum()
In [57]:
tot_idade
Out[57]:
QTD_ELEITORES_16     403683
QTD_ELEITORES_17     996934
QTD_ELEITORES_18    2326608
QTD_ELEITORES_19    2817706
QTD_ELEITORES_20    3034507
dtype: int64
In [59]:
# mostrando os dados no gráfico
tot_idade.plot.barh()
Out[59]:
<matplotlib.axes._subplots.AxesSubplot at 0x127de750>
In [ ]: