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

ℹ Suggested 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.drop(["a"], axis=1, inplace=True)
8 8 | 

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

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

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

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

PD002.py:17: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

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

PD002.py:22: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

ℹ Suggested fix
19 19 |         axis=1,
20 20 |     )
21 21 | 
22    |-x.drop(["a"], axis=1, **kwargs, inplace=True)
   22 |+x = x.drop(["a"], axis=1, **kwargs)
23 23 | x.drop(["a"], axis=1, inplace=True, **kwargs)
24 24 | f(x.drop(["a"], axis=1, inplace=True))

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

PD002.py:24: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
   |


