-
Notifications
You must be signed in to change notification settings - Fork 123
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 attributes to access index dimensions #432
Add attributes to access index dimensions #432
Conversation
Sorry, there may have been a misunderstanding with that comment - the expected behaviour in pandas is that .scenario returns the whole column "scenario", rather than the summary statistics listing only unique scenarios (i.e. the summary info for the column). I'm not sure I would have a preference for this notation over the old notation - it's shorter to write but requires a breaking change. |
Thanks @Rlamboll, you are right, this makes the behavior more similar to pandas but it is still different. I updated the docstrings to at least clarify the behaviour. I understood your comment in response to the overview of an
In light of this, it makes sense to have @gidden @byersiiasa @znicholls @jkikstra, any thoughts? |
This is going to be annoying, but I'd leave the API. Having |
@danielhuppmann this does indeed resolve the inconsistency I was referencing at the time... but I had imagined you would resolve that by adding letter "s"es to the new printouts we were discussing rather than recoding loads of other interfaces! Then it would read "models:" <output of models()> etc. |
Thanks for the feedback! I guess part of the confusion comes from different understanding of what an IamDataFrame is:
I want to move in a direction of (2), whereas you see (1) as the expected behavior - but then, I see a challenging discussion whether I didn't use plurals in the
Important to note that this PR adds an attribute for all index dimensions, not just the standard ones... |
Again, thanks for sharing your concerns! As there were no responses to my previous response, two statements and a follow-up question...
Question: how often have you actually used either of the to-be-deprecated functions ( If you think this is a terrible change, I'll forget the PR - but I still see it as an improvement in the long term. |
I hadn't realised that your point above was a question rather than statement - I have made clear I am in camp 1, and Silicone does not interact with metadata since I don't know what it is or how the new data will change it (although if you append your output to the original df it will be conserved), so camp 2 cannot realistically entice me in without concrete use-cases that readily interconvert with pandas dfs. |
These both make good sense to me!
I don't actually use pyam very much anymore so for me it's never... When I did use it, the answer was also basically never, like you it was only for looking at what was available, never actually a key part of the processing.
Unless I'm mistaken, I'm pretty sure you can do # get a dataframe with unique combos
iamdf.meta[["model", "scenario"]].drop_duplicates()
# you can then make lists or whatever else with some trickery
iamdf.meta[["model", "scenario"]].drop_duplicates().to_records("dict")
iamdf.meta[["model", "scenario"]].drop_duplicates().to_dict("records")
[tuple(v) for _, v in iamdf.meta[["model", "scenario"]].drop_duplicates().iterrows()]
I'm convinced too |
66ad926
to
70229a8
Compare
Please confirm that this PR has done the following:
Description of PR
Per this comment by @Rlamboll that
scenario
would be a more intuitive way to retrieve the list of scenarios compared toscenarios()
, this PR adds the index dimensions as attributes. This is closer to the behavior that a pandas-user would expect.Open questions:
(except for continuous-time, which is a
pandas.DateTimeIndex
)models()
,scenarios()
,regions()
) are marked for deprecation - any objections?variables()
can either return a series (only variables) or a dataframe (variables and units) - any preferences whether to keep this as is, or alternative suggestions?