Skip to content

pandas/inplace-result-assigned

Pack Severity Fix Versions
pandas error unsafe, with xpd check --fix --unsafe-fixes All versions

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.

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

See all rules in the pandas pack.