<jupyter_start><jupyter_text>Israel Elections 2020data source: https://votes23.bechirot.gov.il/<jupyter_code>import pandas as pd
import numpy as np

# read counted votes by city
df = pd.read_csv("https://media23.bechirot.gov.il/files/expc.csv", encoding='iso8859_8')
df.head(2)
# establish list of parties
parties = df.columns[7:-1]

# sum votes and sort
top10 = df[parties].sum().sort_values(ascending=False).head(10)
top10
# extract call letters of top parties
call10 = top10.index.values
call10
# top N cities with disqualified votes
df['disqual_ratio'] = df.eval('פסולים/מצביעים*100')
df[np.concatenate([['פסולים', 'כשרים', 'שם ישוב', 'מצביעים', 'disqual_ratio'], call10])].sort_values(by=['פסולים'], ascending=False).head(10)
# top cities/places for נץ

df['n1'] = df.eval('נץ/מצביעים*100')
df[np.concatenate([['פסולים', 'כשרים', 'שם ישוב', 'מצביעים', 'n1'], call10])].sort_values(by=['n1'], ascending=False).head(10)
# add column r1 for ratio of smillarity to overall results
# nature of r1 is still under question (how to compute)

he_valid = 'כשרים'
he_voters = 'מצביעים'
he_place = 'שם ישוב'

top10r = top10.divide(df[he_valid].sum())
def calcFit(r):
    return(r.filter(items=call10).divide(r[he_valid]) - top10r).abs().sum()

df['fit_index'] = df.apply(lambda x: calcFit(x), axis=1)
df[df[he_voters]>5000][np.concatenate([[he_place, he_voters, he_valid, 'fit_index'], call10])].sort_values(by=['fit_index'], ascending=True).head(20)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17379497623896809, 'fraction_numerical': 0.04344874405974202, 'mean_word_length': 6.677083333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '248713', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 666, 'n_tokens_neox': 617, 'n_words': 117, 'path': 'notebooks/israel-elections-2020.ipynb', 'repo_name': 'dror27/dror-ddj-notebooks', 'size': '1473'}