Skip to content

Commit

Permalink
add viz
Browse files Browse the repository at this point in the history
  • Loading branch information
danlessa committed Nov 18, 2020
1 parent f237e98 commit 5bee925
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions notebooks/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,32 @@

# %%
import pandas as pd
import plotly.express as px
pd.options.plotting.backend = "plotly"


DATA_PATH = '../data/clean_data.csv.gz'

df = pd.read_csv(DATA_PATH, compression='gzip')
# %%
y_1 = (df.query('job == "prefeito"')
.groupby('main_party')
.candidate_vote_count
.sum()
.sort_values())
y_1.name = 'mayor_votes_per_party'
y_1.plot.bar()

# %%
y_2 = (df.query('job == "vereador"')
.groupby('main_party')
.candidate_vote_count
.sum()
.sort_values())
y_2.name = 'councilor_votes_per_party'
y_2.plot.bar()
# %%
fig_df = pd.DataFrame([y_1, y_2]).T
px.scatter(fig_df,
x='mayor_votes_per_party',
y='councilor_votes_per_party')

0 comments on commit 5bee925

Please sign in to comment.