DataFrame.eval(expr, inplace=False, **kwargs)
[source]
Evaluate an expression in the context of the calling DataFrame instance.
Parameters: |
expr : string The expression string to evaluate. inplace : bool, default False If the expression contains an assignment, whether to perform the operation inplace and mutate the existing DataFrame. Otherwise, a new DataFrame is returned. New in version 0.18.0. kwargs : dict See the documentation for |
---|---|
Returns: |
ret : ndarray, scalar, or pandas object |
For more details see the API documentation for eval()
. For detailed examples see enhancing performance with eval.
>>> from numpy.random import randn >>> from pandas import DataFrame >>> df = DataFrame(randn(10, 2), columns=list('ab')) >>> df.eval('a + b') >>> df.eval('c = a + b')
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.22.0/generated/pandas.DataFrame.eval.html