---
source: crates/ruff_linter/src/rules/pandas_vet/mod.rs
---
PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
 --> PD002.py:5:23
  |
3 | x = pd.DataFrame()
4 |
5 | x.drop(["a"], axis=1, inplace=True)
  |                       ^^^^^^^^^^^^
6 |
7 | x.y.drop(["a"], axis=1, inplace=True)
  |
help: Assign to variable; remove `inplace` arg
  |
4 |
  - x.drop(["a"], axis=1, inplace=True)
5 + x = x.drop(["a"], axis=1)
6 |
  |
note: This is an unsafe fix and may change runtime behavior

PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
 --> PD002.py:7:25
  |
5 | x.drop(["a"], axis=1, inplace=True)
6 |
7 | x.y.drop(["a"], axis=1, inplace=True)
  |                         ^^^^^^^^^^^^
8 |
9 | x["y"].drop(["a"], axis=1, inplace=True)
  |
help: Assign to variable; remove `inplace` arg
  |
6 |
  - x.y.drop(["a"], axis=1, inplace=True)
7 + x.y = x.y.drop(["a"], axis=1)
8 |
  |
note: This is an unsafe fix and may change runtime behavior

PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
  --> PD002.py:9:28
   |
 7 | x.y.drop(["a"], axis=1, inplace=True)
 8 |
 9 | x["y"].drop(["a"], axis=1, inplace=True)
   |                            ^^^^^^^^^^^^
10 |
11 | x.drop(
   |
help: Assign to variable; remove `inplace` arg
   |
8  |
   - x["y"].drop(["a"], axis=1, inplace=True)
9  + x["y"] = x["y"].drop(["a"], axis=1)
10 |
   |
note: This is an unsafe fix and may change runtime behavior

PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
  --> PD002.py:12:5
   |
11 | x.drop(
12 |     inplace=True,
   |     ^^^^^^^^^^^^
13 |     columns=["a"],
14 |     axis=1,
   |
help: Assign to variable; remove `inplace` arg
   |
10 |
   - x.drop(
   -     inplace=True,
11 + x = x.drop(
12 |     columns=["a"],
   |
note: This is an unsafe fix and may change runtime behavior

PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
  --> PD002.py:19:9
   |
17 | if True:
18 |     x.drop(
19 |         inplace=True,
   |         ^^^^^^^^^^^^
20 |         columns=["a"],
21 |         axis=1,
   |
help: Assign to variable; remove `inplace` arg
   |
17 | if True:
   -     x.drop(
   -         inplace=True,
18 +     x = x.drop(
19 |         columns=["a"],
   |
note: This is an unsafe fix and may change runtime behavior

PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
  --> PD002.py:24:33
   |
22 |     )
23 |
24 | x.drop(["a"], axis=1, **kwargs, inplace=True)
   |                                 ^^^^^^^^^^^^
25 | x.drop(["a"], axis=1, inplace=True, **kwargs)
26 | f(x.drop(["a"], axis=1, inplace=True))
   |
help: Assign to variable; remove `inplace` arg
   |
23 |
   - x.drop(["a"], axis=1, **kwargs, inplace=True)
24 + x = x.drop(["a"], axis=1, **kwargs)
25 | x.drop(["a"], axis=1, inplace=True, **kwargs)
   |
note: This is an unsafe fix and may change runtime behavior

PD002 `inplace=True` should be avoided; it has inconsistent behavior
  --> PD002.py:25:23
   |
24 | x.drop(["a"], axis=1, **kwargs, inplace=True)
25 | x.drop(["a"], axis=1, inplace=True, **kwargs)
   |                       ^^^^^^^^^^^^
26 | f(x.drop(["a"], axis=1, inplace=True))
   |
help: Assign to variable; remove `inplace` arg

PD002 `inplace=True` should be avoided; it has inconsistent behavior
  --> PD002.py:26:25
   |
24 | x.drop(["a"], axis=1, **kwargs, inplace=True)
25 | x.drop(["a"], axis=1, inplace=True, **kwargs)
26 | f(x.drop(["a"], axis=1, inplace=True))
   |                         ^^^^^^^^^^^^
27 |
28 | x.apply(lambda x: x.sort_values("a", inplace=True))
   |
help: Assign to variable; remove `inplace` arg

PD002 `inplace=True` should be avoided; it has inconsistent behavior
  --> PD002.py:28:38
   |
26 | f(x.drop(["a"], axis=1, inplace=True))
27 |
28 | x.apply(lambda x: x.sort_values("a", inplace=True))
   |                                      ^^^^^^^^^^^^
29 | import torch
   |
help: Assign to variable; remove `inplace` arg

PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
  --> PD002.py:33:24
   |
31 | torch.m.ReLU(inplace=True)  # safe because this isn't a pandas call
32 |
33 | (x.drop(["a"], axis=1, inplace=True))
   |                        ^^^^^^^^^^^^
34 |
35 | # This method doesn't take exist in Pandas, so ignore it.
   |
help: Assign to variable; remove `inplace` arg
   |
32 |
   - (x.drop(["a"], axis=1, inplace=True))
33 + x = (x.drop(["a"], axis=1))
34 |
   |
note: This is an unsafe fix and may change runtime behavior
