pyam icon indicating copy to clipboard operation
pyam copied to clipboard

Filter by level does not work with multiple conditions

Open Rlamboll opened this issue 3 years ago • 1 comments

As far as I can work out, "df.filter(level=[1, 2])" always produces nothing, even when "df.filter(level=1)" and "df.filter(level=2)" produce reasonable values. I have been using workarounds so far, but at some point we should probably fix this!

Rlamboll avatar Dec 01 '22 14:12 Rlamboll

The level argument is passed to https://github.com/IAMconsortium/pyam/blob/83b75423de26e3a322dcd1ea9c61069d234f4dc8/pyam/utils.py#L417

And the docstring of the function clearly states that it can be an int or a str (like 1+).

Fine for me to either extend the function or raise an explicit error.

Also, we should add level to the list of illegal column names in an IamDataFrame. Using an extra-column named level would cause unexpected behavior for the filter method.

https://github.com/IAMconsortium/pyam/blob/83b75423de26e3a322dcd1ea9c61069d234f4dc8/pyam/utils.py#L34

danielhuppmann avatar Dec 01 '22 14:12 danielhuppmann