You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Try to respond to as many of the following as possible
Generally describe the pandas behavior that the linter should check for and why that is a problem.Links to resources, recommendations, docs appreciated
The linter should check for nunique being compared to 1. The detected pattern is less performant because it does not leverage short-circuiting when multiple unique values are found, and simply continues counting..
Thanks for flagging this, @sbrugman. This would be nice to add, indeed. We can match the PD101 code from ruff if it gets done.
Side note: I had no idea ruff wrapped in the pandas-vet checks!
This repo isn't very active (pandas doesn't change much these days) but it is still alive. I just made a number of long-overdue improvements to docs and CI/CD that should hopefully keep things current for a while.
Try to respond to as many of the following as possible
Generally describe the
pandas
behavior that the linter should check for and why that is a problem. Links to resources, recommendations, docs appreciatedThe linter should check for nunique being compared to 1. The detected pattern is less performant because it does not leverage short-circuiting when multiple unique values are found, and simply continues counting..
Suggest specific syntax or pattern(s) that should trigger the linter (e.g.,
.iat
)df.column.nunique() == 1
df.column.nunique() != 1
df.column.nunique(dropna=True) == 1
df.column.nunique(dropna=True) != 1
df.column.nunique(dropna=False) == 1
df.column.nunique(dropna=False) != 1
Suggest specific syntax or pattern(s) that the linter should allow (e.g.,
.iloc
)Note that the solution is simple when there are no NaN values:
And needs some additional logic when NaN/NA values are present.
For
dropna=True
For
dropna=False
if included in pandas:
Suggest a specific error message that the linter should display (e.g., "Use '.iloc' instead of '.iat'. If speed is important, use numpy indexing")
Consider checking equality to first element instead of
.nunique() == 1
for checking for a constant column.Are you willing to try to implement this check?
The text was updated successfully, but these errors were encountered: