-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an Iamslice
#657
Add an Iamslice
#657
Conversation
Codecov Report
@@ Coverage Diff @@
## main #657 +/- ##
=======================================
- Coverage 94.5% 94.5% -0.1%
=======================================
Files 57 59 +2
Lines 5662 5742 +80
=======================================
+ Hits 5356 5431 +75
- Misses 306 311 +5
Continue to review full report at Codecov.
|
Well it is a My main argument for showing the Series representation is that it being a Series opens up several interesting computations, that people might want to know about, which don't make so much sense, if you don't know it is a boolean series. The most interesting one is that you can do boolean operations, ie if you want from your example s_scen_a = test_df.slice(scenario="scen_a")
s_coal = test_df.slice(variable="*|Coal")
s_scen_a & ~ s_coal will give you <class 'pyam.slice.IamSlice'>
Index dimensions and data coordinates:
model : model_a (1)
scenario : scen_a (1)
region : World (1)
variable : Primary Energy (1)
unit : EJ/yr (1)
year : 2005, 2010 (2)
model scenario region variable unit year
model_a scen_a World Primary Energy EJ/yr 2005 True
2010 True
Primary Energy|Coal EJ/yr 2005 False
2010 False
scen_b World Primary Energy EJ/yr 2005 False
2010 False
dtype: bool |
I agree with the implementation and behavior. I'm just worried that implementing Options:
|
I guess the overview is what is going to be the most helpful. So, i'd vote rather for showing the overview, ie option 2 (although, i like seeing both). ie. let's keep it as it is here now. Then we can merge! What this PR is missing and what is leftover as a new PR would be to refactor the second half of IamDataFrame.filter into a new method (could be called (Currently |
Please confirm that this PR has done the following:
Name of contributors Added to AUTHORS.rstDescription of PR
This PR implements an
IamSlice
based on the initial work by @coroa in #637. I rebased the branch and added basic documentation.One question: in the initial work,
__repr__
combined a summary similar to an IamDataFrame and a representation of the pd.Series. In the usual test case filtered for `scenario="scen_b", this yields.I find that a bit confusing, because the list of variables shows only "Primary Energy" but the series also shows "Primary Energy|Coal" (as False, but still). I therefore removed the second part, so that
__repr__
only shows the summary overview.If you think that having the slice as pd.Series, we could add a method
as_series()
.