Page MenuHomec4science

plot_delegation_sizes.py
No OneTemporary

File Metadata

Created
Fri, Oct 18, 21:24

plot_delegation_sizes.py

import pandas as pd
import matplotlib.pyplot as plt
def plot(path):
country_data = pd.DataFrame(columns={"meeting", "USA", "China", "Germany", "Saudi Arabia", "Brazil", "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")
try:
total_DE = len(grouped_by_country.get_group("Germany"))
total_US = len(grouped_by_country.get_group("United States"))
total_CN = len(grouped_by_country.get_group("China"))
total_SA = len(grouped_by_country.get_group("Saudi Arabia"))
total_BR = len(grouped_by_country.get_group("Brazil"))
total_CH = len(grouped_by_country.get_group("Switzerland"))
except KeyError:
print(i)
print(f"{total_DE} DE and {total_US} US and {total_CN} CN and {total_SA} SA and {total_BR} BR and {total_CH} CH")
total_DE = 0
total_US = 0
total_CN = 0
total_SA = 0
total_BR = 0
total_CH = 0
country_data = country_data.append({
"meeting": "cop" + str(i),
"USA": total_US,
"China": total_CN,
"Germany": total_DE,
"Saudi Arabia": total_SA,
"Brazil": total_BR,
"Switzerland": total_CH
}, ignore_index=True)
total_DE = 0
total_US = 0
total_CN = 0
total_SA = 0
total_BR = 0
total_CH = 0
plot_data4 = country_data.set_index("meeting")
plot_data4.plot(kind="line", xlabel="Meeting", ylabel="Delegation size",
title="Delegation size", ylim=(0, 600))
plt.show()

Event Timeline