Skip to content

pandas/inplace-result-assigned

Rule inplace-result-assigned
Pack pandas
Severity error
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions every version

A call with inplace=True returns None, so df = df.dropna(inplace=True) sets df to None. Drop inplace=True and keep the assignment.

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

The rule reports df = df.dropna(inplace=True), which sets df to None.

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 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.

A call with inplace=True returns None, so $NAME is None after this line. Drop inplace=True and keep the assignment.

Browse the other rules of the pandas pack.