-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
Pandas' .query()
and .eval()
support some methods calls on columns, for example df.query("a.isna()")
or df.eval("b.fillna(33.33)")
. However, this doesn't work with nested columns:
from nested_pandas.datasets import generate_data
nf = generate_data(12, 5)
nf = nf.query("a.notna()") # works
_ = nf["nested"].notna() # works
_ = nf.query("nested.notna()") # fails
File ~/.virtualenvs/v/lib/python3.13/site-packages/pandas/core/computation/expr.py:413, in BaseExprVisitor.visit(self, node, **kwargs)
411 method = f"visit_{type(node).__name__}"
412 visitor = getattr(self, method)
--> 413 return visitor(node, **kwargs)
File ~/.virtualenvs/v/lib/python3.13/site-packages/pandas/core/computation/expr.py:659, in BaseExprVisitor.visit_Call(self, node, side, **kwargs)
657 def visit_Call(self, node, side=None, **kwargs):
658 if isinstance(node.func, ast.Attribute) and node.func.attr != "__call__":
--> 659 res = self.visit_Attribute(node.func)
660 elif not isinstance(node.func, ast.Name):
661 raise TypeError("Only named functions are supported")
File ~/.virtualenvs/v/lib/python3.13/site-packages/pandas/core/computation/expr.py:646, in BaseExprVisitor.visit_Attribute(self, node, **kwargs)
644 resolved = self.visit(value).value
645 try:
--> 646 v = getattr(resolved, attr)
647 name = self.env.add_tmp(v)
648 return self.term_type(name, self.env)
File ~/.virtualenvs/v/lib/python3.13/site-packages/nested_pandas/nestedframe/expr.py:168, in _NestedFieldResolver.__getattr__(self, item_name)
166 result.flat_nest = self._flat_nest
167 return result
--> 168 raise AttributeError(f"No attribute {item_name}")
AttributeError: No attribute isna
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 description 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