@@ -749,46 +749,6 @@ def add_resolvers_to_locals(self):
749
749
self .env .locals .update (self .env .resolver_dict )
750
750
751
751
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
-
792
752
def isexpr (s , check_names = True ):
793
753
"""Strict checking for a valid expression."""
794
754
try :
0 commit comments