File size: 672 Bytes
cf66726
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)