<jupyter_start><jupyter_text>Election data<jupyter_code>ballot_df = pd.read_csv("PyPoll/Resources/election_data.csv")
ballot_df.head()<jupyter_output><empty_output><jupyter_text>Dataframe and plots grouped by Candidate<jupyter_code>grouped_by_candidate_ballot_df = ballot_df.groupby("Candidate").count()
del grouped_by_candidate_ballot_df["County"]
grouped_by_candidate_ballot_df.head()
grouped_by_candidate_ballot_df.plot(kind="bar", y="Voter ID", title="Voting Outcome")
plt.ylabel("Number of Votes")
grouped_by_candidate_ballot_df.plot(kind="pie", x="Candidate", y="Voter ID", title="Vote Percentages")<jupyter_output><empty_output><jupyter_text>Dataframe and plots grouped by County<jupyter_code>grouped_by_county_ballot_df = ballot_df.groupby("County").count()
del grouped_by_county_ballot_df["Candidate"]
grouped_by_county_ballot_df.head()
grouped_by_county_ballot_df.plot(kind="bar", y="Voter ID", title="County Vote Distribution")
plt.ylabel("Number of Votes")
grouped_by_county_and_candidate_ballot_df = ballot_df.groupby(["County", "Candidate"]).count()
grouped_by_county_and_candidate_ballot_df.head(20)<jupyter_output><empty_output><jupyter_text>Individual County Plots<jupyter_code>Counties = ballot_df["County"].unique()
Counties

for county in Counties:
    grouped_by_county_and_candidate_ballot_df.loc[county,:].plot(kind="bar", title=f"{county} County Voting Outcome")
    plt.ylabel("Number of Votes")
    
    grouped_by_county_and_candidate_ballot_df.loc[county,:].plot(kind="pie", x="Candidate",
                                                                 y="Voter ID", title=f"{county} County Vote Percentages")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12402636309167166, 'fraction_numerical': 0.0011983223487118035, 'mean_word_length': 7.978494623655914, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '492807', 'license': 'ADSL', 'n_tokens_mistral': 629, 'n_tokens_neox': 607, 'n_words': 73, 'path': '.ipynb_checkpoints/Election Plotting-checkpoint.ipynb', 'repo_name': 'camiloibanez/python-challenge', 'size': '1669'}