Skip to content

Commit

Permalink
MAINT: Default inplace to False in pd.eval
Browse files Browse the repository at this point in the history
Deprecated back in 0.18.0

xref pandas-devgh-11149

[ci skip]
  • Loading branch information
gfyoung committed Jun 20, 2017
1 parent 196eb8e commit bf6fbe5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.21.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Removal of prior version deprecations/changes

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


.. _whatsnew_0210.performance:
Expand Down
16 changes: 2 additions & 14 deletions pandas/core/computation/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _check_for_locals(expr, stack_level, parser):

def eval(expr, parser='pandas', engine=None, truediv=True,
local_dict=None, global_dict=None, resolvers=(), level=0,
target=None, inplace=None):
target=None, inplace=False):
"""Evaluate a Python expression as a string using various backends.
The following arithmetic operations are supported: ``+``, ``-``, ``*``,
Expand Down Expand Up @@ -207,14 +207,10 @@ def eval(expr, parser='pandas', engine=None, truediv=True,
scope. Most users will **not** need to change this parameter.
target : a target object for assignment, optional, default is None
essentially this is a passed in resolver
inplace : bool, default True
inplace : bool, default False
If expression mutates, whether to modify object inplace or return
copy with mutation.
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.
Returns
-------
ndarray, numeric scalar, DataFrame, Series
Expand Down Expand Up @@ -272,14 +268,6 @@ def eval(expr, parser='pandas', engine=None, truediv=True,

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

# if returning a copy, copy only on the first assignment
if not inplace and first_expr:
Expand Down
8 changes: 0 additions & 8 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,14 +1311,6 @@ def assignment_not_inplace(self):
expected['c'] = expected['a'] + expected['b']
tm.assert_frame_equal(df, expected)

# Default for inplace will change
with tm.assert_produces_warnings(FutureWarning):
df.eval('c = a + b')

# but don't warn without assignment
with tm.assert_produces_warnings(None):
df.eval('a + b')

def test_multi_line_expression(self):
# GH 11149
df = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})
Expand Down

0 comments on commit bf6fbe5

Please sign in to comment.