pylint-dev / pylint-ml

Pylint plugin enhancing code analysis for machine learning and data science
MIT License
2 stars 0 forks source link

add-pandas-inplace-parameter-set-checker #26

Closed PeterHamfelt closed 1 month ago

PeterHamfelt commented 5 months ago

Avoid using pandas inplace=True parameter.

  1. Clarity and Maintainability: Code that uses inplace=True can be harder to read and maintain, as the changes to the DataFrame or Series are not immediately visible, leading to possible side effects.
  2. Performance: The perceived performance benefits of inplace=True are often misunderstood. In many cases, pandas creates a copy of the data anyway, so the memory and performance advantages may be negligible.
  3. Chained Operations: Using inplace=True in chained operations can lead to errors since the result of an inplace operation is None.

References https://stackoverflow.com/questions/43893457/understanding-inplace-true-in-pandas https://github.com/pandas-dev/pandas/issues/16529