unstoppable_app / racial_equity_endorsements.py
veeps
merging all endorsements into one file
cf66726
raw
history blame
672 Bytes
import pandas as pd
# Read in endorsements
coc = pd.read_csv("coc_endorsements.csv")
splc = pd.read_csv("splc_endorsements.csv")
# Merge by name
df = pd.merge(coc[["Candidate", "Endorsed by"]], splc[["Candidate", "Endorsed by"]], on = "Candidate", how = "outer")
# Fill NaN values with an empty string for concatenation
df.fillna('', inplace = True)
# Concatenate the endorsements into a single string
df['Endorsed by'] = df['Endorsed by_x'] + ', ' + df['Endorsed by_y']
df['Endorsed by'] = df['Endorsed by'].str.strip(', ')
df.drop(columns=["Endorsed by_x", "Endorsed by_y"], inplace = True)
# Write to CSV
df.to_csv("racial_equity_endorsements.csv", index = False)