pyam
pyam copied to clipboard
add weighted quantiles
Description of PR
Adds a df.quantile()
function which calculates (possibly weighted) quantiles for a variable across a population of models and scenarios.
If this feature is useful for others in the community, I'm happy to improve the PR, add a tutorial, etc.
cc @chrisroadmap
Please confirm that this PR has done the following:
- [x] Tests Added
- [x] Documentation Added
- ~[ ] Name of contributors Added to AUTHORS.rst~
- [ ] Description in RELEASE_NOTES.md Added
TODOS
- [ ] support custom names (currently put into
model
)
Adding to RELEASE_NOTES.md (remove section after adding to RELEASE_NOTES.md)
Please add a single line in the release notes similar to the following:
- (#XX)[http://link-to-pr.com] Added feature which does something
Codecov Report
Merging #686 (84c69ea) into main (947d8c4) will increase coverage by
0.0%
. The diff coverage is93.2%
.
@@ Coverage Diff @@
## main #686 +/- ##
=====================================
Coverage 94.8% 94.9%
=====================================
Files 58 59 +1
Lines 5899 5990 +91
=====================================
+ Hits 5598 5690 +92
+ Misses 301 300 -1
Impacted Files | Coverage Δ | |
---|---|---|
pyam/iiasa.py | 86.7% <ø> (ø) |
|
tests/test_iiasa.py | 97.8% <ø> (-0.1%) |
:arrow_down: |
tests/test_io.py | 98.4% <85.7%> (-1.6%) |
:arrow_down: |
pyam/compute.py | 96.2% <91.6%> (-3.8%) |
:arrow_down: |
pyam/core.py | 95.2% <100.0%> (+0.6%) |
:arrow_up: |
pyam/utils.py | 91.7% <100.0%> (ø) |
|
tests/test_feature_quantiles.py | 100.0% <100.0%> (ø) |
|
tests/test_ops.py | 100.0% <0.0%> (ø) |
|
tests/test_core.py | 100.0% <0.0%> (ø) |
|
tests/test_feature_validation.py | 100.0% <0.0%> (ø) |
|
... and 2 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Thanks @gidden, this sounds really useful!
A few comments:
- I developed a Statistics module for the SR15, see the docs and a real-world use case here. The main advantage of the Statistics class is that you often want to do quantiles on groups of scenarios (e.g., the temperature categorization). If I understand the current implementation correctly, the method will always compute quantiles grouped by scenario names indexed by model, region and variable - we should probably anticipate a more flexible approach.
- If you proceed with implementation in this way, I suggest to add that as method like
IamDataFrame.compute.quantiles()
to avoid too many methods directly on the IamDataFrame class. See the docs.
@danielhuppmann - FYI - I am seeing test failures in test_datareader.py
not related to this PR.
I'm also hoping to clean this up, time permitting, in the next days.
@danielhuppmann - FYI - I am seeing test failures in test_datareader.py not related to this PR.
But all checks except one passed, so I guess that the Woldbank-server just had a hick-up in that second. Re-running the failed test might do the trick...
all committed, should be g2g @danielhuppmann ! Thanks for the review!
Release notes are still missing - pretty please!
Release notes updated and issues made @danielhuppmann
Thanks @gidden!