from pandas_datapackage_reader import read_datapackage
da = read_datapackage("https://github.com/openclimatedata/doha-amendment-entry-into-force")
da.head()
pa = read_datapackage("https://github.com/openclimatedata/paris-agreement-entry-into-force")
pa.head()
combined = pa.reset_index().merge(da.reset_index(), how="outer").set_index('Code')
combined = combined.rename(columns={
"Acceptance": "Doha",
"Ratification-Acceptance-Approval": "Paris"
})
combined = combined[["Doha", "Paris"]].dropna(how="all")
combined = combined.join(pa.Name, how="left")[["Name", "Doha", "Paris"]]
combined.count()
only_doha = combined[combined.Paris.isnull()]
only_doha
only_paris = combined[combined.Doha.isnull()]
only_paris
both = combined[~combined.Paris.isnull() & ~combined.Doha.isnull()]
both
print("Doha only: {}\nParis only: {}\nBoth Doha and Paris: {}".format(len(only_doha), len(only_paris), len(both)))