Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cdp_data/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ class CDPInstances:
Richmond = "cdp-richmond-a3d06941"
Louisville = "cdp-louisville-6fd32a38"
Atlanta = "cdp-atlanta-37e7dd70"

all_instances = [Seattle, KingCounty, Portland, Missoula, Denver, Alameda, Boston, Oakland, Charlotte, SanJose,
MountainView, Milwaukee, LongBeach, Albuquerque, Richmond, Louisville, Atlanta]
37 changes: 37 additions & 0 deletions cdp_data/tests/voting_analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from cdp_data import CDPInstances, datasets


def voting_analysis(cdp_instance:str, start_datetime:str, end_datetime:str,):
ds = datasets.get_vote_dataset(cdp_instance,start_datetime=start_datetime,end_datetime=end_datetime,replace_py_objects=True)

ds=ds[['matter_id','event_datetime','event_minutes_item_overall_decision','in_majority','decision','person_name']].sort_values(by=['matter_id'])

#all of the voting in the system
ds_all_votes = ds.groupby(['matter_id','event_datetime','event_minutes_item_overall_decision'])

#all of the votings that passed
df_passed = ds_all_votes['event_minutes_item_overall_decision'].apply(lambda x: (x == 'Passed').sum()).reset_index(name='count')

#all of voting that were not unanimous
df_count_objection = ds.groupby(['matter_id'])['in_majority'].apply(lambda x: (x == False).sum()).reset_index(name='count')
df_count_objection = df_count_objection[df_count_objection['count'] != 0]
# print(ds_all_votes)
# print(df_passed)
# print(df_count_objection)
return (len(ds_all_votes),len(df_passed),len(df_count_objection))


"""
f = open("council_vote_data.txt", "a")


for instance in CDPInstances.all_instances:
res = voting_analysis(instance, "2022-10-01", "2022-10-31")
f.write(instance + "\t" + str(res[0]) + "\t" + str(res[1]) + "\t" + str(res[2]))
f.write("\n")

f.close()
"""

res = voting_analysis(CDPInstances.Oakland, "2022-10-01", "2022-10-30")
print(res)