openclimatedata / globalwarmingpotentials

Global Warming Potentials as assessed by the IPCC in CSV format, and as Python and Node modules
Creative Commons Zero v1.0 Universal
22 stars 8 forks source link

Python API suggestion - nested dictionary as internal dictionary #3

Closed danielhuppmann closed 3 years ago

danielhuppmann commented 3 years ago

I think that a nested dictionary would make more sense on the Python API, so that is easier to see which GWP-metrics exist... (Finding out which attributes exist seems a bit messy).

_data = {
    SARGWP100 = {
        "CH4": 21.0,
    ...
}

and two public API functions:

def metrics():
    return list(_data)

def get_values(metric):
    return _data[metric]
znicholls commented 3 years ago

+1 from me

rgieseke commented 3 years ago

A nested dict was my initial attempt as well, i liked the slightly simpler auto-completion (which is now great for dict keys as well, just a little bit more typing), but i agree that this is simpler.

See a proposal in #4 -- i don't think special API functions are necessary, one could use .keys() or list(globalwarmingpotentials) directly i think.

I've also added an optional Pandas Data Frame.

rgieseke commented 3 years ago

Closed in #4