Skip to content

Commit ab60f4b

Browse files
committed
CLN: remove expr maybe_expression
1 parent 50502fb commit ab60f4b

File tree

2 files changed

+1
-41
lines changed

2 files changed

+1
-41
lines changed

pandas/computation/expr.py

-40
Original file line numberDiff line numberDiff line change
@@ -749,46 +749,6 @@ def add_resolvers_to_locals(self):
749749
self.env.locals.update(self.env.resolver_dict)
750750

751751

752-
# these we don't look for since column names can have these characters
753-
_needs_filter = frozenset(['and', 'or', 'not', 'not in', 'in'])
754-
755-
# these OTOH can only be operators, so you cannot create column names that are
756-
# valid expressions
757-
_ops_to_filter = frozenset([' and ', ' or ', 'not ', ' in '])
758-
759-
# if you don't filter out the above expressions you'll get a stack overflow,
760-
# because DataFrame.__getitem__ will continue to search for a column name then
761-
# an expression then a column name then an expression, and so on, until you
762-
# blow up the stack and kill a kitten.
763-
764-
765-
def maybe_expression(s, kind='pandas'):
766-
"""Loose checking if ``s`` is an expression.
767-
768-
Parameters
769-
----------
770-
s : str or unicode
771-
The expression to check
772-
kind : str or unicode
773-
The parser whose ops to check
774-
775-
Returns
776-
-------
777-
bool
778-
``True`` the expression contains some operators that would be valid
779-
when parsed with the ``kind`` parser, otherwise ``False``.
780-
"""
781-
if not isinstance(s, string_types):
782-
return False
783-
784-
visitor = _parsers[kind]
785-
ops = visitor.binary_ops + visitor.unary_ops
786-
filtered = (frozenset(ops) | _ops_to_filter) - _needs_filter
787-
788-
# make sure we have an op at least
789-
return any(op in s for op in filtered)
790-
791-
792752
def isexpr(s, check_names=True):
793753
"""Strict checking for a valid expression."""
794754
try:

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from pandas.core.series import Series, _radd_compat
3838
import pandas.computation.expressions as expressions
3939
from pandas.computation.eval import eval as _eval
40-
from pandas.computation.expr import maybe_expression, _ensure_scope
40+
from pandas.computation.expr import _ensure_scope
4141
from pandas.compat.scipy import scoreatpercentile as _quantile
4242
from pandas.compat import(range, zip, lrange, lmap, lzip, StringIO, u,
4343
OrderedDict, raise_with_traceback)

0 commit comments

Comments
 (0)