Skip to content

pandas/no-inplace

Rule no-inplace
Pack pandas
Severity info, and warning with style = "strict". A rule of the house style
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions every version

inplace=True gives no speedup and keeps the call out of a method chain. Assign the result instead.

df.dropna(inplace=True)
df = df.dropna()

The rule reports any other inplace=True, which gives no speedup and keeps the call out of a method chain.

xpd check --fix --unsafe-fixes applies the fixes of this rule. Check the result, because an unsafe fix can change what the code does.

The unsafe fix writes df = df.dropna().

The fix applies only to a call that stands alone as a statement, on a name, an attribute or a subscript. It drops comments between the arguments of the call.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

inplace=True gives no speedup and blocks chaining. Reassign instead.

Browse the other rules of the pandas pack.