Open beskep opened 11 months ago
Difficult for us to fully resolve this without a full type inference engine (we could use heuristics, like avoid flagging these rules if polars
is imported, but that comes with other problems: you don't have to import Polars in order to access a Polars DataFrame, and just because you import Polars doesn't mean you aren't working with Pandas DataFrames anywhere). Likely won't be fixed in the near-term.
(I'd recommend against using these rules if you're working with Polars.)
for a simpler heuristic, would it be possible to check the alias used to instantiate the dataframe? pl.DataFrame
rather than pd.DataFrame
gives a pretty strong clue that it's not pandas
Currently the pandas rules are applied on many non pandas objects. For example PD011 tries to stop you from using .values anywhere, even if you use a library where you should use it. Therefore some kind of check, if the object is even belonging to pandas would be pretty useful.
The same thing happens with the Python DEAP
package which has class members named values
.
command:
ruff check test.py
ruff version:ruff 0.0.282
settings:select = ['ALL']
example:
polars DataFrame provides
.pivot()
function but no.pivot_table()
unlike pandas.