Skip to content

Commit bf6fbe5

Browse files
committed
MAINT: Default inplace to False in pd.eval
Deprecated back in 0.18.0 xref gh-11149 [ci skip]
1 parent 196eb8e commit bf6fbe5

File tree

3 files changed

+3
-22
lines changed

3 files changed

+3
-22
lines changed

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Removal of prior version deprecations/changes
7676

7777
- ``pd.read_excel()`` has dropped the ``has_index_names`` parameter (:issue:`10967`)
7878
- ``Categorical`` has dropped the ``.order()`` and ``.sort()`` methods in favor of ``.sort_values()`` (:issue:`12882`)
79+
- ``pd.eval`` has changed the default of ``inplace`` from ``None`` to ``False`` (:issue:`11149`)
7980

8081

8182
.. _whatsnew_0210.performance:

pandas/core/computation/eval.py

+2-14
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def _check_for_locals(expr, stack_level, parser):
148148

149149
def eval(expr, parser='pandas', engine=None, truediv=True,
150150
local_dict=None, global_dict=None, resolvers=(), level=0,
151-
target=None, inplace=None):
151+
target=None, inplace=False):
152152
"""Evaluate a Python expression as a string using various backends.
153153
154154
The following arithmetic operations are supported: ``+``, ``-``, ``*``,
@@ -207,14 +207,10 @@ def eval(expr, parser='pandas', engine=None, truediv=True,
207207
scope. Most users will **not** need to change this parameter.
208208
target : a target object for assignment, optional, default is None
209209
essentially this is a passed in resolver
210-
inplace : bool, default True
210+
inplace : bool, default False
211211
If expression mutates, whether to modify object inplace or return
212212
copy with mutation.
213213
214-
WARNING: inplace=None currently falls back to to True, but
215-
in a future version, will default to False. Use inplace=True
216-
explicitly rather than relying on the default.
217-
218214
Returns
219215
-------
220216
ndarray, numeric scalar, DataFrame, Series
@@ -272,14 +268,6 @@ def eval(expr, parser='pandas', engine=None, truediv=True,
272268

273269
# assign if needed
274270
if env.target is not None and parsed_expr.assigner is not None:
275-
if inplace is None:
276-
warnings.warn(
277-
"eval expressions containing an assignment currently"
278-
"default to operating inplace.\nThis will change in "
279-
"a future version of pandas, use inplace=True to "
280-
"avoid this warning.",
281-
FutureWarning, stacklevel=3)
282-
inplace = True
283271

284272
# if returning a copy, copy only on the first assignment
285273
if not inplace and first_expr:

pandas/tests/computation/test_eval.py

-8
Original file line numberDiff line numberDiff line change
@@ -1311,14 +1311,6 @@ def assignment_not_inplace(self):
13111311
expected['c'] = expected['a'] + expected['b']
13121312
tm.assert_frame_equal(df, expected)
13131313

1314-
# Default for inplace will change
1315-
with tm.assert_produces_warnings(FutureWarning):
1316-
df.eval('c = a + b')
1317-
1318-
# but don't warn without assignment
1319-
with tm.assert_produces_warnings(None):
1320-
df.eval('a + b')
1321-
13221314
def test_multi_line_expression(self):
13231315
# GH 11149
13241316
df = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})

0 commit comments

Comments
 (0)