Page MenuHomec4science

plot_delegation_exp.py
No OneTemporary

File Metadata

Created
Sat, Nov 16, 04:29

plot_delegation_exp.py

import pandas as pd
import matplotlib.pyplot as plt
# TODO update to newer numbers of experience
def plot(path):
country_data = pd.DataFrame(columns={"meeting", "USA", "China", "European Union", "Saudi Arabia", "Kenya", "Switzerland"})
complete_data = pd.read_csv(path,
encoding="utf-8-sig")
for i in range(1, 26):
data = complete_data[complete_data["meeting"] == "cop" + str(i)]
grouped_by_country = data.groupby("affiliation")
total_EU = 0
total_US = 0
total_CN = 0
total_SA = 0
total_KE = 0
total_CH = 0
for aff, people in grouped_by_country:
if aff == "Switzerland":
total_CH = people["experience"].sum() / len(people)
elif aff == "United States":
total_US = people["experience"].sum() / len(people)
elif aff == "China":
total_CN = people["experience"].sum() / len(people)
elif aff.lower() == "european union" or aff.lower() == "european community":
total_EU = people["experience"].sum() / len(people)
elif aff == "Saudi Arabia":
total_SA = people["experience"].sum() / len(people)
elif aff == "Kenya":
total_KE = people["experience"].sum() / len(people)
country_data = country_data.append({
"meeting": "cop" + str(i),
"USA": total_US,
"China": total_CN,
"European Union": total_EU,
"Saudi Arabia": total_SA,
"Kenya": total_KE,
"Switzerland": total_CH
}, ignore_index=True)
plot_data = country_data.set_index("meeting")
plot_data.plot(kind="line", xlabel="Meeting", ylabel="Experience Score",
title="Experience score per party")
plt.show()

Event Timeline