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

ℹ Unsafe fix
2 2 | 
3 3 | x = pd.DataFrame()
4 4 | 
5   |-x.drop(["a"], axis=1, inplace=True)
  5 |+x = x.drop(["a"], axis=1)
6 6 | 
7 7 | x.y.drop(["a"], axis=1, inplace=True)
8 8 | 

PD002.py:7:25: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
  |
5 | x.drop(["a"], axis=1, inplace=True)
6 | 
7 | x.y.drop(["a"], axis=1, inplace=True)
  |                         ^^^^^^^^^^^^ PD002
8 | 
9 | x["y"].drop(["a"], axis=1, inplace=True)
  |
  = help: Assign to variable; remove `inplace` arg

ℹ Unsafe fix
4 4 | 
5 5 | x.drop(["a"], axis=1, inplace=True)
6 6 | 
7   |-x.y.drop(["a"], axis=1, inplace=True)
  7 |+x.y = x.y.drop(["a"], axis=1)
8 8 | 
9 9 | x["y"].drop(["a"], axis=1, inplace=True)
10 10 | 

PD002.py:9:28: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
   |
 7 | x.y.drop(["a"], axis=1, inplace=True)
 8 | 
 9 | x["y"].drop(["a"], axis=1, inplace=True)
   |                            ^^^^^^^^^^^^ PD002
10 | 
11 | x.drop(
   |
   = help: Assign to variable; remove `inplace` arg

ℹ Unsafe fix
6  6  | 
7  7  | x.y.drop(["a"], axis=1, inplace=True)
8  8  | 
9     |-x["y"].drop(["a"], axis=1, inplace=True)
   9  |+x["y"] = x["y"].drop(["a"], axis=1)
10 10 | 
11 11 | x.drop(
12 12 |     inplace=True,

PD002.py:12:5: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
   |
11 | x.drop(
12 |     inplace=True,
   |     ^^^^^^^^^^^^ PD002
13 |     columns=["a"],
14 |     axis=1,
   |
   = help: Assign to variable; remove `inplace` arg

ℹ Unsafe fix
8  8  | 
9  9  | x["y"].drop(["a"], axis=1, inplace=True)
10 10 | 
11    |-x.drop(
12    |-    inplace=True,
   11 |+x = x.drop(
13 12 |     columns=["a"],
14 13 |     axis=1,
15 14 | )

PD002.py:19:9: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
   |
17 | if True:
18 |     x.drop(
19 |         inplace=True,
   |         ^^^^^^^^^^^^ PD002
20 |         columns=["a"],
21 |         axis=1,
   |
   = help: Assign to variable; remove `inplace` arg

ℹ Unsafe fix
15 15 | )
16 16 | 
17 17 | if True:
18    |-    x.drop(
19    |-        inplace=True,
   18 |+    x = x.drop(
20 19 |         columns=["a"],
21 20 |         axis=1,
22 21 |     )

PD002.py:24:33: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior
   |
22 |     )
23 | 
24 | x.drop(["a"], axis=1, **kwargs, inplace=True)
   |                                 ^^^^^^^^^^^^ PD002
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

ℹ Unsafe fix
21 21 |         axis=1,
22 22 |     )
23 23 | 
24    |-x.drop(["a"], axis=1, **kwargs, inplace=True)
   24 |+x = x.drop(["a"], axis=1, **kwargs)
25 25 | x.drop(["a"], axis=1, inplace=True, **kwargs)
26 26 | f(x.drop(["a"], axis=1, inplace=True))
27 27 | 

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

PD002.py:26:25: PD002 `inplace=True` should be avoided; it has inconsistent behavior
   |
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))
   |                         ^^^^^^^^^^^^ PD002
27 | 
28 | x.apply(lambda x: x.sort_values("a", inplace=True))
   |
   = help: Assign to variable; remove `inplace` arg

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

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

ℹ Unsafe fix
30 30 | 
31 31 | torch.m.ReLU(inplace=True)  # safe because this isn't a pandas call
32 32 | 
33    |-(x.drop(["a"], axis=1, inplace=True))
   33 |+x = (x.drop(["a"], axis=1))
34 34 | 
35 35 | # This method doesn't take exist in Pandas, so ignore it.
36 36 | x.rotate_z(45, inplace=True)


