-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
BugRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version
Milestone
Description
From SO question (http://stackoverflow.com/questions/23974664/unable-to-query-a-local-variable-in-pandas-0-14-0), referencing a local variable gives an error when this is a string (workaround seems to be to wrap it in a list):
In [39]: fills = pd.DataFrame({'Symbol':['BUD US', 'BUD US', 'IBM US', 'IBM US'], 'Price':[109.70, 109.72, 183.30, 183.35]}) In [40]: fills Out[40]: Price Symbol 0 109.70 BUD US 1 109.72 BUD US 2 183.30 IBM US 3 183.35 IBM US In [41]: my_symbol = ['BUD US'] In [42]: fills.query('Symbol==@my_symbol') Out[42]: Price Symbol 0 109.70 BUD US 1 109.72 BUD US In [43]: my_symbol = 'BUD US' In [44]: fills.query('Symbol==@my_symbol') --------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-44-c16846018a13> in <module>() ----> 1 fills.query('Symbol==@my_symbol') ... /home/joris/scipy/pandas/pandas/computation/expr.pyc in _rewrite_membership_op(self, node, left, right) 341 # of one string, kind of a hack 342 if right_str: --> 343 self.env.remove_tmp(right.name) 344 name = self.env.add_tmp([right.value]) 345 right = self.term_type(name, self.env) /home/joris/scipy/pandas/pandas/computation/scope.pyc in remove_tmp(self, name) 287 The name of a temporary to be removed 288 """ --> 289 del self.temps[name] 290 291 @property KeyError: '__pd_eval_local_my_symbol' > /home/joris/scipy/pandas/pandas/computation/scope.py(289)remove_tmp() 288 """ --> 289 del self.temps[name] 290 Metadata
Metadata
Assignees
Labels
BugRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version