diff --git "a/jupyterlite/notebooks/emendas/2 Cruzamento e an\303\241lise.ipynb" "b/jupyterlite/notebooks/emendas/2 Cruzamento e an\303\241lise.ipynb" index ff42963..1615a71 100644 --- "a/jupyterlite/notebooks/emendas/2 Cruzamento e an\303\241lise.ipynb" +++ "b/jupyterlite/notebooks/emendas/2 Cruzamento e an\303\241lise.ipynb" @@ -31,7 +31,7 @@ } ], "source": [ - "%pip install -q fastparquet plotly nbformat>=4.2.0" + "%pip install -q fastparquet plotly nbformat" ] }, { @@ -41,10 +41,33 @@ "metadata": {}, "outputs": [], "source": [ + "import locale\n", + "\n", "import pandas as pd\n", "import plotly.graph_objects as go" ] }, + { + "cell_type": "code", + "execution_count": 3, + "id": "15480ffb-1526-4eeb-a867-c06ed0ffa77c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'pt_BR.UTF-8'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "locale.setlocale(locale.LC_ALL, 'pt_BR.UTF-8')" + ] + }, { "cell_type": "markdown", "id": "9badbc8d-b669-41a9-b531-38681a6911b3", @@ -57,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "id": "24c52cf8-1e96-408e-9cdc-c5bf181212ed", "metadata": {}, "outputs": [], @@ -67,7 +90,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "id": "32f126d6-f712-4d20-94cf-3de8d5e2af08", "metadata": {}, "outputs": [], @@ -77,7 +100,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "id": "264ed6f0-5e78-4a0a-98bf-2bed63d1d3c0", "metadata": {}, "outputs": [], @@ -110,7 +133,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "d1a4b261-410a-472e-9b2a-474cb68f5567", "metadata": {}, "outputs": [ @@ -136,7 +159,7 @@ " 'Silvio Antonio'}" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -160,7 +183,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "db78bf30-82ec-402d-a559-37de46d20d4c", "metadata": { "colab": { @@ -606,7 +629,7 @@ "[10934 rows x 36 columns]" ] }, - "execution_count": 7, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -667,7 +690,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "id": "bf866b4f-6f29-442a-ad5b-769fd672779a", "metadata": { "colab": { @@ -687,7 +710,7 @@ "Name: count, dtype: int64" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -698,7 +721,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "id": "803bc0c6-617e-4058-bd22-1ea91ab17009", "metadata": {}, "outputs": [ @@ -729,7 +752,7 @@ "Name: count, dtype: int64" ] }, - "execution_count": 9, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -741,7 +764,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "id": "7f565fc7-a3ac-495b-b162-6c7302214e82", "metadata": { "scrolled": true @@ -765,7 +788,7 @@ "Name: count, dtype: int64" ] }, - "execution_count": 10, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -785,7 +808,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "id": "c2117dea-8db7-48b2-a493-c52308d228f5", "metadata": { "id": "GLBrg7ptdt5Y" @@ -800,7 +823,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "id": "6b96f916-f61f-4534-bd94-daab22b25549", "metadata": { "id": "CnbdggEberg1" @@ -820,7 +843,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "id": "9dcad2c1-ba0e-4234-a435-e6e14696fa94", "metadata": { "colab": { @@ -853,7 +876,7 @@ "Name: valor_emenda, dtype: float64" ] }, - "execution_count": 13, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -865,14 +888,62 @@ " .sum()\n", " ['valor_emenda']\n", " .sort_values(ascending=False)\n", - " .head(15)\n", ")\n", - "df_emendas_deputados\n" + "df_emendas_deputados.head(15)" ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, + "id": "855db066-ceb2-453e-82f0-98afe52ef499", + "metadata": {}, + "outputs": [], + "source": [ + "def bar_plot(df: pd.DataFrame, title: str, x_label: str, y_label: str):\n", + " \"\"\"Função para criar o gráfico de barras usando o Plotly.\"\"\"\n", + " # Criando o gráfico de barras horizontais\n", + " fig = go.Figure(go.Bar(\n", + " x=df.values,\n", + " y=df.index.map(lambda x: f\"{x[0]} ({x[1]}/{x[2]})\"),\n", + " orientation='h',\n", + " marker_color='skyblue'\n", + " ))\n", + " \n", + " # Adicionando título e rótulos aos eixos\n", + " fig.update_layout(\n", + " title=title,\n", + " xaxis_title=x_label,\n", + " yaxis_title=y_label,\n", + " font_size=12\n", + " )\n", + " \n", + " # Adicionando os valores nas barras\n", + " for i, value in enumerate(df.values):\n", + " fig.add_annotation(\n", + " x=value,\n", + " y=i,\n", + " text=f'{value:,.2f}',\n", + " textangle=0,\n", + " font_size=10,\n", + " showarrow=False,\n", + " align='left',\n", + " xanchor='right'\n", + " )\n", + " \n", + " # Ajustando o layout\n", + " fig.update_layout(\n", + " height=600,\n", + " width=800,\n", + " bargap=0.1\n", + " )\n", + " \n", + " # Exibindo o gráfico\n", + " fig.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 16, "id": "d5aee8ae-4d36-4055-8ab6-08de1828433e", "metadata": { "colab": { @@ -1966,7 +2037,7 @@ } }, "title": { - "text": "Top 10 Deputados por Valor de Emendas" + "text": "15 dos Deputados que mais gastaram emendas" }, "width": 800, "xaxis": { @@ -1982,9 +2053,9 @@ } }, "text/html": [ - "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Criando o gráfico de barras\n", + "fig = go.Figure(go.Bar(\n", + " x=df_distribuicao_emendas_deputados[\"Percentual da cota\"],\n", + " y=df_distribuicao_emendas_deputados['Quantidade de Deputados'],\n", + " marker_color='skyblue',\n", + "))\n", + "\n", + "# Adicionando título e rótulos aos eixos\n", + "fig.update_layout(\n", + " title='Distribuição dos Deputados por Valor de Emendas',\n", + " xaxis_title='Faixa de Valor das Emendas',\n", + " yaxis_title='Número de Deputados',\n", + " font_size=12\n", + ")\n", + "\n", + "# Exibindo o gráfico\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "id": "ba1d6d07-2ced-494c-8472-ae6ad692ccba", + "metadata": {}, + "source": [ + "##### Senado" + ] + }, + { + "cell_type": "markdown", + "id": "62d069c9-d625-4708-9125-2c383e07afb2", + "metadata": {}, + "source": [ + "Os senadores que mais gastaram emendas." + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "670d5ac6-a81a-48f7-8258-f657bc54b0ca", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 429 + }, + "id": "KuO38U6Aewyl", + "outputId": "075c698e-6cc2-4ec1-fb4c-d54e33c9f9b0" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "nome partido uf\n", + "Marcos Rogério PL RO 34817425.0\n", + "Jussara Lima PSD PI 34817425.0\n", + "Jayme Campos UNIÃO MT 34817425.0\n", + "Davi Alcolumbre UNIÃO AP 34815000.0\n", + "Otto Alencar PSD BA 34634850.0\n", + "Ciro Nogueira PP PI 34634850.0\n", + "Giordano MDB SP 34500000.0\n", + "Eliziane Gama PSD MA 34317425.0\n", + "Fernando Farias MDB AL 34317425.0\n", + "Angelo Coronel PSD BA 34134850.0\n", + "Name: valor_emenda, dtype: float64" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_emendas_senadores = (\n", + " df_emendas[df_emendas['cargo']=='senador']\n", + " .groupby(colunas_agregacao)\n", + " .sum()\n", + " ['valor_emenda']\n", + " .sort_values(ascending=False)\n", + ")\n", + "df_emendas_senadores.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "901ad9fa-27da-4750-8e9b-c5c2372da6ed", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 429 + }, + "id": "a6stdnTjeyqZ", + "outputId": "5579a341-b234-47c0-a98f-b2432012ebbe" + }, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "marker": { + "color": "skyblue" + }, + "orientation": "h", + "type": "bar", + "x": [ + 34817425, + 34817425, + 34817425, + 34815000, + 34634850, + 34634850, + 34500000, + 34317425, + 34317425, + 34134850 + ], + "y": [ + "Marcos Rogério (PL/RO)", + "Jussara Lima (PSD/PI)", + "Jayme Campos (UNIÃO/MT)", + "Davi Alcolumbre (UNIÃO/AP)", + "Otto Alencar (PSD/BA)", + "Ciro Nogueira (PP/PI)", + "Giordano (MDB/SP)", + "Eliziane Gama (PSD/MA)", + "Fernando Farias (MDB/AL)", + "Angelo Coronel (PSD/BA)" + ] + } + ], + "layout": { + "annotations": [ + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "34,817,425.00", + "textangle": 0, + "x": 34817425, + "xanchor": "right", + "y": 0 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "34,817,425.00", + "textangle": 0, + "x": 34817425, + "xanchor": "right", + "y": 1 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "34,817,425.00", + "textangle": 0, + "x": 34817425, + "xanchor": "right", + "y": 2 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "34,815,000.00", + "textangle": 0, + "x": 34815000, + "xanchor": "right", + "y": 3 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "34,634,850.00", + "textangle": 0, + "x": 34634850, + "xanchor": "right", + "y": 4 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "34,634,850.00", + "textangle": 0, + "x": 34634850, + "xanchor": "right", + "y": 5 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "34,500,000.00", + "textangle": 0, + "x": 34500000, + "xanchor": "right", + "y": 6 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "34,317,425.00", + "textangle": 0, + "x": 34317425, + "xanchor": "right", + "y": 7 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "34,317,425.00", + "textangle": 0, + "x": 34317425, + "xanchor": "right", + "y": 8 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "34,134,850.00", + "textangle": 0, + "x": 34134850, + "xanchor": "right", + "y": 9 + } + ], + "bargap": 0.1, + "font": { + "size": 12 + }, + "height": 600, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "10 Senadores que mais gastaram Emendas" + }, + "width": 800, + "xaxis": { + "title": { + "text": "Valor Total das Emendas" + } + }, + "yaxis": { + "title": { + "text": "Senadores" + } + } + } + }, + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "bar_plot(\n", + " df_emendas_senadores.head(10),\n", + " title=\"10 Senadores que mais gastaram Emendas\",\n", + " x_label=\"Valor Total das Emendas\",\n", + " y_label=\"Senadores\",\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "1e77bdcf-4f5b-4abe-9172-d869de2dcd69", + "metadata": {}, + "source": [ + "Quantos senadores gastaram o valor máximo?" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "76e2314b-3fad-4f02-8ed4-81de51882c80", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Valor máximo: R$ 34.817.425,00\n", + "Quantidade de senadores que usaram este valor: 3\n" + ] + } + ], + "source": [ + "print(\n", + " f\"Valor máximo: R$ {locale.format_string('%.2f', df_emendas_senadores.max(), grouping=True)}\\n\"\n", + " \"Quantidade de senadores que usaram este valor: \",\n", + " len(df_emendas_senadores[df_emendas_senadores.values == df_emendas_senadores.values.max()])\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "8089713d-c853-4515-bf44-14566935ffee", + "metadata": {}, + "source": [ + "Os senadores que menos gastaram emendas." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "ccc00880-02c0-41ea-acd4-bb4d16eda8c0", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 429 + }, + "id": "a6stdnTjeyqZ", + "outputId": "5579a341-b234-47c0-a98f-b2432012ebbe" + }, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "marker": { + "color": "skyblue" + }, + "orientation": "h", + "type": "bar", + "x": [ + 16100000, + 14677420, + 14022000, + 10000000, + 9250000, + 9000000, + 3555317, + 3500000, + 1800000, + 1500000 + ], + "y": [ + "Humberto Costa (PT/PE)", + "Flávio Arns (PSB/PR)", + "Zequinha Marinho (PODEMOS/PA)", + "Weverton (PDT/MA)", + "Sérgio Petecão (PSD/AC)", + "Mara Gabrilli (PSD/SP)", + "Vanderlan Cardoso (PSD/GO)", + "Marcos do Val (PODEMOS/ES)", + "Romário (PL/RJ)", + "Leila Barros (PDT/DF)" + ] + } + ], + "layout": { + "annotations": [ + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "16,100,000.00", + "textangle": 0, + "x": 16100000, + "xanchor": "right", + "y": 0 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "14,677,420.00", + "textangle": 0, + "x": 14677420, + "xanchor": "right", + "y": 1 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "14,022,000.00", + "textangle": 0, + "x": 14022000, + "xanchor": "right", + "y": 2 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "10,000,000.00", + "textangle": 0, + "x": 10000000, + "xanchor": "right", + "y": 3 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "9,250,000.00", + "textangle": 0, + "x": 9250000, + "xanchor": "right", + "y": 4 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "9,000,000.00", + "textangle": 0, + "x": 9000000, + "xanchor": "right", + "y": 5 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "3,555,317.00", + "textangle": 0, + "x": 3555317, + "xanchor": "right", + "y": 6 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "3,500,000.00", + "textangle": 0, + "x": 3500000, + "xanchor": "right", + "y": 7 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "1,800,000.00", + "textangle": 0, + "x": 1800000, + "xanchor": "right", + "y": 8 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "1,500,000.00", + "textangle": 0, + "x": 1500000, + "xanchor": "right", + "y": 9 + } + ], + "bargap": 0.1, + "font": { + "size": 12 + }, + "height": 600, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "10 Senadores que menos gastaram Emendas" + }, + "width": 800, + "xaxis": { + "title": { + "text": "Valor Total das Emendas" + } + }, + "yaxis": { + "title": { + "text": "Senadores" + } + } + } + }, + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "bar_plot(\n", + " df_emendas_senadores.tail(10),\n", + " title=\"10 Senadores que menos gastaram Emendas\",\n", + " x_label=\"Valor Total das Emendas\",\n", + " y_label=\"Senadores\",\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "5c057f46-f352-424a-804b-9d23fd4926ca", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
FaixaQuantidade de SenadoresPercentual da cota
0R\\$ 1,500,000.00 - R\\$ 4,831,742.5040% - 10%
1R\\$ 4,831,742.50 - R\\$ 8,163,485.00010% - 20%
2R\\$ 8,163,485.00 - R\\$ 11,495,227.50320% - 30%
3R\\$ 11,495,227.50 - R\\$ 14,826,970.00230% - 40%
4R\\$ 14,826,970.00 - R\\$ 18,158,712.50340% - 50%
5R\\$ 18,158,712.50 - R\\$ 21,490,455.00850% - 60%
6R\\$ 21,490,455.00 - R\\$ 24,822,197.50860% - 70%
7R\\$ 24,822,197.50 - R\\$ 28,153,940.001270% - 80%
8R\\$ 28,153,940.00 - R\\$ 31,485,682.50980% - 90%
9R\\$ 31,485,682.50 - R\\$ 34,817,425.001590% - 100%
\n", + "
" + ], + "text/plain": [ + " Faixa Quantidade de Senadores \\\n", + "0 R\\$ 1,500,000.00 - R\\$ 4,831,742.50 4 \n", + "1 R\\$ 4,831,742.50 - R\\$ 8,163,485.00 0 \n", + "2 R\\$ 8,163,485.00 - R\\$ 11,495,227.50 3 \n", + "3 R\\$ 11,495,227.50 - R\\$ 14,826,970.00 2 \n", + "4 R\\$ 14,826,970.00 - R\\$ 18,158,712.50 3 \n", + "5 R\\$ 18,158,712.50 - R\\$ 21,490,455.00 8 \n", + "6 R\\$ 21,490,455.00 - R\\$ 24,822,197.50 8 \n", + "7 R\\$ 24,822,197.50 - R\\$ 28,153,940.00 12 \n", + "8 R\\$ 28,153,940.00 - R\\$ 31,485,682.50 9 \n", + "9 R\\$ 31,485,682.50 - R\\$ 34,817,425.00 15 \n", + "\n", + " Percentual da cota \n", + "0 0% - 10% \n", + "1 10% - 20% \n", + "2 20% - 30% \n", + "3 30% - 40% \n", + "4 40% - 50% \n", + "5 50% - 60% \n", + "6 60% - 70% \n", + "7 70% - 80% \n", + "8 80% - 90% \n", + "9 90% - 100% " + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Encontrando o valor máximo e mínimo das emendas\n", + "max_valor = df_emendas_senadores.max()\n", + "min_valor = df_emendas_senadores.min()\n", + "\n", + "# Dividindo o intervalo em 10 faixas iguais\n", + "faixa_size = (max_valor - min_valor) / 10\n", + "faixas = [min_valor + i * faixa_size for i in range(11)]\n", + "\n", + "# Contando o número de deputados em cada faixa\n", + "faixa_counts = [\n", + " len(df_emendas_senadores[(df_emendas_senadores >= faixas[i]) & (df_emendas_senadores < faixas[i+1])])\n", + " for i in range(10)\n", + "]\n", + "\n", + "# Criando o dataframe\n", + "df_distribuicao_emendas_senadores = pd.DataFrame({\n", + " 'Faixa': [f'R\\$ {faixas[i]:,.2f} - R\\$ {faixas[i+1]:,.2f}' for i in range(10)],\n", + " 'Quantidade de Senadores': faixa_counts,\n", + " 'Percentual da cota': [f\"{i * 10}% - {(i+1) * 10}%\" for i in range(10)]\n", + "})\n", + "df_distribuicao_emendas_senadores" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "8760f192-c612-4efa-b6dd-4db2d610a49c", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "marker": { + "color": "skyblue" + }, + "type": "bar", + "x": [ + "0% - 10%", + "10% - 20%", + "20% - 30%", + "30% - 40%", + "40% - 50%", + "50% - 60%", + "60% - 70%", + "70% - 80%", + "80% - 90%", + "90% - 100%" + ], + "y": [ + 4, + 0, + 3, + 2, + 3, + 8, + 8, + 12, + 9, + 15 + ] + } + ], + "layout": { + "font": { + "size": 12 + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Distribuição dos Senadores por Valor de Emendas" + }, + "xaxis": { + "title": { + "text": "Faixa de Valor das Emendas" + } + }, + "yaxis": { + "title": { + "text": "Quantidade de Senadores" + } + } + } + }, + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Criando o gráfico de barras\n", + "fig = go.Figure(go.Bar(\n", + " x=df_distribuicao_emendas_senadores[\"Percentual da cota\"],\n", + " y=df_distribuicao_emendas_senadores['Quantidade de Senadores'],\n", + " marker_color='skyblue',\n", + "))\n", + "\n", + "# Adicionando título e rótulos aos eixos\n", + "fig.update_layout(\n", + " title='Distribuição dos Senadores por Valor de Emendas',\n", + " xaxis_title='Faixa de Valor das Emendas',\n", + " yaxis_title='Quantidade de Senadores',\n", + " font_size=12\n", + ")\n", + "\n", + "# Exibindo o gráfico\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "id": "9adce570-7f74-44ac-9445-cbea933647ec", + "metadata": {}, + "source": [ + "#### Valores totais por beneficiário" + ] + }, + { + "cell_type": "markdown", + "id": "dbf47b1f-fc14-4305-ba82-9d27c47a98cf", + "metadata": {}, + "source": [ + "Quantidade de emendas por beneficiário:" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "acce1821-528e-4214-82ca-4fcd4a4a33bc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "nome_beneficiario_plano_acao\n", + "ESTADO DE MINAS GERAIS 29\n", + "ESTADO DA BAHIA 22\n", + "ESTADO DE SAO PAULO 21\n", + "ESTADO DO ACRE 18\n", + "MUNICIPIO DE PORTO ALEGRE 17\n", + " ..\n", + "LUTÉCIA 1\n", + "MUNICIPIO DE ITUMIRIM 1\n", + "MUNICIPIO DE IBITURUNA 1\n", + "MUNICIPIO DE CANELA 1\n", + "MUNICIPIO DE ITACOATIARA 1\n", + "Name: count, Length: 4458, dtype: int64" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_emendas.nome_beneficiario_plano_acao.value_counts()" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "c7292dc8-267a-4474-89f8-bda2e9a58265", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "nome_beneficiario_plano_acao\n", + "ESTADO DA BAHIA 106139019.0\n", + "ESTADO DE MATO GROSSO DO SUL 67253544.0\n", + "ESTADO DE SAO PAULO 51593567.0\n", + "MUNICIPIO DE MACAPA 46299542.0\n", + "ESTADO DO ACRE 40565055.0\n", + "ESTADO DO PIAUI 32849182.0\n", + "COARI 31434456.0\n", + "MUNICIPIO DE COTIA 30071292.0\n", + "ESTADO DE MINAS GERAIS 29689690.0\n", + "MUNICIPIO DE CARAPICUIBA 24555054.0\n", + "MUNICIPIO DE SAO PAULO 24100000.0\n", + "ESTADO DO ESPIRITO SANTO 24090812.0\n", + "MUNICIPIO DE BOA VISTA 23935794.0\n", + "ESTADO DO MARANHAO 22557377.0\n", + "MUNICIPIO DE SAO LUIZ 21935792.0\n", + "Name: valor_emenda, dtype: float64" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_emendas_beneficiario_camara = (\n", + " df_emendas[df_emendas['cargo']=='deputado']\n", + " .groupby([\"nome_beneficiario_plano_acao\"])\n", + " .sum()\n", + " ['valor_emenda']\n", + " .sort_values(ascending=False)\n", + ")\n", + "df_emendas_beneficiario_camara.head(15)" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "00a12e37-da51-48bd-a777-265ef3104a2a", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "marker": { + "color": "skyblue" + }, + "orientation": "h", + "type": "bar", + "x": [ + 106139019, + 67253544, + 51593567, + 46299542, + 40565055, + 32849182, + 31434456, + 30071292, + 29689690, + 24555054, + 24100000, + 24090812, + 23935794, + 22557377, + 21935792 + ], + "y": [ + "ESTADO DA BAHIA", + "ESTADO DE MATO GROSSO DO SUL", + "ESTADO DE SAO PAULO", + "MUNICIPIO DE MACAPA", + "ESTADO DO ACRE", + "ESTADO DO PIAUI", + "COARI", + "MUNICIPIO DE COTIA", + "ESTADO DE MINAS GERAIS", + "MUNICIPIO DE CARAPICUIBA", + "MUNICIPIO DE SAO PAULO", + "ESTADO DO ESPIRITO SANTO", + "MUNICIPIO DE BOA VISTA", + "ESTADO DO MARANHAO", + "MUNICIPIO DE SAO LUIZ" + ] + } + ], + "layout": { + "annotations": [ + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "106,139,019.00", + "textangle": 0, + "x": 106139019, + "xanchor": "right", + "y": 0 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "67,253,544.00", + "textangle": 0, + "x": 67253544, + "xanchor": "right", + "y": 1 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "51,593,567.00", + "textangle": 0, + "x": 51593567, + "xanchor": "right", + "y": 2 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "46,299,542.00", + "textangle": 0, + "x": 46299542, + "xanchor": "right", + "y": 3 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "40,565,055.00", + "textangle": 0, + "x": 40565055, + "xanchor": "right", + "y": 4 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "32,849,182.00", + "textangle": 0, + "x": 32849182, + "xanchor": "right", + "y": 5 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "31,434,456.00", + "textangle": 0, + "x": 31434456, + "xanchor": "right", + "y": 6 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "30,071,292.00", + "textangle": 0, + "x": 30071292, + "xanchor": "right", + "y": 7 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "29,689,690.00", + "textangle": 0, + "x": 29689690, + "xanchor": "right", + "y": 8 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "24,555,054.00", + "textangle": 0, + "x": 24555054, + "xanchor": "right", + "y": 9 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "24,100,000.00", + "textangle": 0, + "x": 24100000, + "xanchor": "right", + "y": 10 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "24,090,812.00", + "textangle": 0, + "x": 24090812, + "xanchor": "right", + "y": 11 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "23,935,794.00", + "textangle": 0, + "x": 23935794, + "xanchor": "right", + "y": 12 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "22,557,377.00", + "textangle": 0, + "x": 22557377, + "xanchor": "right", + "y": 13 + }, + { + "align": "left", + "font": { + "size": 10 + }, + "showarrow": false, + "text": "21,935,792.00", + "textangle": 0, + "x": 21935792, + "xanchor": "right", + "y": 14 + } + ], + "bargap": 0.1, + "font": { + "size": 12 + }, + "height": 600, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "15 beneficiários que mais receberam emendas" + }, + "width": 800, + "xaxis": { + "title": { + "text": "Beneficiário" + } + }, + "yaxis": { + "title": { + "text": "Total em emendas" + } + } + } + }, + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Criando o gráfico de barras horizontais\n", + "fig = go.Figure(go.Bar(\n", + " x=df_emendas_beneficiario_camara.head(15).values,\n", + " y=df_emendas_beneficiario_camara.head(15).index,\n", + " orientation='h',\n", + " marker_color='skyblue'\n", + "))\n", + "\n", + "# Adicionando título e rótulos aos eixos\n", + "fig.update_layout(\n", + " title=\"15 beneficiários que mais receberam emendas\",\n", + " xaxis_title=\"Beneficiário\",\n", + " yaxis_title=\"Total em emendas\",\n", + " font_size=12\n", + ")\n", + "\n", + "# Adicionando os valores nas barras\n", + "for i, value in enumerate(df_emendas_beneficiario_camara.head(15).values):\n", " fig.add_annotation(\n", " x=value,\n", " y=i,\n",