<jupyter_start><jupyter_text>CommitteesExtract ballot measure committees from the database, as well as their many-to-one links to propositions<jupyter_code>import os
import settings
import pandas as pd<jupyter_output><empty_output><jupyter_text>Pull in all ballot measures<jupyter_code>props = pd.read_csv(os.path.join(settings.data_dir, "props.csv"))
props.sort_values("ccdc_prop_id").head()<jupyter_output><empty_output><jupyter_text>Pull in all ballot-measure committees<jupyter_code>committees = pd.read_sql_table("calaccess_processed_scrapedpropositioncommittee", settings.db_connection)
trimmed_committees = committees[[
    'id',
    'scraped_id',
    'proposition_id',
    'name',
    'position'
]].rename(columns={
    "id": "ccdc_committee_id",
    "scraped_id": "calaccess_committee_id",
    "proposition_id": "ccdc_prop_id",
    "name": "committee_name",
    "position": "committee_position"
})
trimmed_committees.head()<jupyter_output><empty_output><jupyter_text>Merge them together<jupyter_code>merged = pd.merge(props, trimmed_committees, how="inner", on="ccdc_prop_id")
merged.head()
merged.to_csv(os.path.join(settings.data_dir, 'committees-and-props.csv'), index=False)
distinct_committees = merged.groupby([
    'calaccess_committee_id',
    'committee_name'
]).size().reset_index()
distinct_committees.rename(columns={0: "prop_count"}, inplace=True)
distinct_committees.to_csv(
    os.path.join(settings.data_dir, 'committees.csv'),
    index=False
)<jupyter_output><empty_output><jupyter_text>Filter down to the most recent election<jupyter_code>recent_props = pd.read_csv(os.path.join(settings.data_dir, "props-2016.csv"))
recent_merged = pd.merge(
    recent_props,
    trimmed_committees,
    how="inner",
    on="ccdc_prop_id"
)
recent_merged.head()
recent_merged.to_csv(
    os.path.join(settings.data_dir, 'committees-and-props-2016.csv'),
    index=False
)
recent_distinct_committees = recent_merged.groupby([
    'calaccess_committee_id',
    'committee_name'
]).size().reset_index()
recent_distinct_committees.rename(columns={0: "prop_count"}, inplace=True)
recent_distinct_committees.head()
recent_distinct_committees.to_csv(
    os.path.join(settings.data_dir, 'committees-2016.csv'),
    index=False
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13206713780918727, 'fraction_numerical': 0.006183745583038869, 'mean_word_length': 7.206521739130435, 'pattern_counts': {'":': 5, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '242719', 'license': 'MIT', 'n_tokens_mistral': 856, 'n_tokens_neox': 796, 'n_words': 110, 'path': 'calaccess-exploration/propositions/02_committees.ipynb', 'repo_name': 'california-civic-data-coalition/python-calacess-notebooks', 'size': '2264'}