#!/usr/bin/env python # coding: utf-8 # # Explore UNFCCC emissions data # In[1]: import os from pathlib import Path import numpy as np import pandas as pd import matplotlib.pyplot as plt # In[2]: # data directory data_dir = Path(os.path.abspath("../data/processed/")) data_file = data_dir / "unfccc-ghg-without-lulucf-1990-2021.csv" # load data df = pd.read_csv(data_file) # # 1. Who are the top 10 emitters for 2021 # In[3]: df.loc[df['year'] == 2021].sort_values(by='emissions_gt',ascending=False)[0:10] # In[4]: top10 = list(df.loc[df['year'] == 2021].sort_values(by='emissions_gt',ascending=False)[0:10]['party']) # In[5]: for party in top10: data = df.loc[df['party'] == party] plt.plot(data['year'], data['emissions_gt'], label=party) plt.xlabel('Year') plt.ylabel('Emissions (gigatonne)') plt.legend(title='Country', bbox_to_anchor=(1.05, 1), loc='upper left') # In[ ]: