Skip to content

CLN: remove pd import in pandas/core/computation #39268

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

Merged
merged 2 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pandas/core/computation/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,19 +558,19 @@ def visit_Index(self, node, **kwargs):
return self.visit(node.value)

def visit_Subscript(self, node, **kwargs):
import pandas as pd
from pandas import eval as pd_eval

value = self.visit(node.value)
slobj = self.visit(node.slice)
result = pd.eval(
result = pd_eval(
slobj, local_dict=self.env, engine=self.engine, parser=self.parser
)
try:
# a Term instance
v = value.value[result]
except AttributeError:
# an Op instance
lhs = pd.eval(
lhs = pd_eval(
value, local_dict=self.env, engine=self.engine, parser=self.parser
)
v = lhs[result]
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

from pandas.core.dtypes.common import is_list_like

import pandas as pd
import pandas.core.common as com
from pandas.core.computation import expr, ops, scope as _scope
from pandas.core.computation.common import ensure_decoded
from pandas.core.computation.expr import BaseExprVisitor
from pandas.core.computation.ops import UndefinedVariableError, is_term
from pandas.core.construction import extract_array
from pandas.core.indexes.base import Index

from pandas.io.formats.printing import pprint_thing, pprint_thing_encoded

Expand Down Expand Up @@ -250,7 +250,7 @@ def convert_values(self):


class FilterBinOp(BinOp):
filter: Optional[Tuple[Any, Any, pd.Index]] = None
filter: Optional[Tuple[Any, Any, Index]] = None

def __repr__(self) -> str:
if self.filter is None:
Expand Down Expand Up @@ -285,7 +285,7 @@ def evaluate(self):
if self.op in ["==", "!="] and len(values) > self._max_selectors:

filter_op = self.generate_filter_op()
self.filter = (self.lhs, filter_op, pd.Index(values))
self.filter = (self.lhs, filter_op, Index(values))

return self
return None
Expand All @@ -294,7 +294,7 @@ def evaluate(self):
if self.op in ["==", "!="]:

filter_op = self.generate_filter_op()
self.filter = (self.lhs, filter_op, pd.Index(values))
self.filter = (self.lhs, filter_op, Index(values))

else:
raise TypeError(
Expand Down