-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
We cannot use built-in methods in queries because of an issue in the query parsing code:
from nested_pandas import NestedFrame
nf = NestedFrame.from_flat(NestedFrame({'a': [1, 2], 'b': [3, None]}, index=[1,1]), base_columns=[])
nf.query("nested.b.isna()")File ~/.virtualenvs/v/lib/python3.12/site-packages/nested_pandas/nestedframe/core.py:357, in NestedFrame.query(self, expr)
313 """
314 Query the columns of a NestedFrame with a boolean expression. Specified
315 queries can target nested columns in addition to the typical column set
(...)
353 >>> df.query("mynested.a > 2")
354 """
356 # Rebuild queries for each specified nested/base layer
--> 357 exprs_to_use = self._split_query(expr)
359 # For now (simplicity), limit query to only operating on one layer
360 if len(exprs_to_use.keys()) != 1:
File ~/.virtualenvs/v/lib/python3.12/site-packages/nested_pandas/nestedframe/core.py:293, in NestedFrame._split_query(self, expr)
291 expr_slice = split_expr[i].strip("()")
292 # Check if it's a nested column
--> 293 if self._is_known_hierarchical_column(expr_slice):
294 nested, colname = split_expr[i].split(".")
295 current_focus = nested.strip("()")
File ~/.virtualenvs/v/lib/python3.12/site-packages/nested_pandas/nestedframe/core.py:58, in NestedFrame._is_known_hierarchical_column(self, colname)
56 """Determine whether a string is a known hierarchical column name"""
57 if "." in colname:
---> 58 left, right = colname.split(".")
59 if left in self.nested_columns:
60 return right in self.all_columns[left]
ValueError: too many values to unpack (expected 2)
I believe it is related to #144, but probably would need a different fix
Before submitting
Please check the following:
- I have described the situation in which the bug arose, including what code was executed, information about my environment, and any applicable data others will need to reproduce the problem.
- I have included available evidence of the unexpected behavior (including error messages, screenshots, and/or plots) as well as a descriprion of what I expected instead.
- If I have a solution in mind, I have provided an explanation and/or pseudocode and/or task list.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working