-
DataFrame.eval(expr, inplace=None, **kwargs)
[source] -
Evaluate an expression in the context of the calling DataFrame instance.
Parameters: expr : string
The expression string to evaluate.
inplace : bool
If the expression contains an assignment, whether to return a new DataFrame or mutate the existing.
WARNING: inplace=None currently falls back to to True, but in a future version, will default to False. Use inplace=True explicitly rather than relying on the default.
New in version 0.18.0.
kwargs : dict
See the documentation for
eval()
for complete details on the keyword arguments accepted byquery()
.Returns: ret : ndarray, scalar, or pandas object
Notes
For more details see the API documentation for
eval()
. For detailed examples see enhancing performance with eval.Examples
12345>>>
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'
)
DataFrame.eval()

2025-01-10 15:47:30
Please login to continue.