Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLC1901 false-positives with pandas #3494

Closed
twoertwein opened this issue Mar 13, 2023 · 0 comments · Fixed by #3517
Closed

PLC1901 false-positives with pandas #3494

twoertwein opened this issue Mar 13, 2023 · 0 comments · Fixed by #3517

Comments

@twoertwein
Copy link

twoertwein commented Mar 13, 2023

import pandas as pd

data =  pd.DataFrame({"a": ["", "abc", "xyz"]})

data.loc[data["a"] != ""]  # PLC1901
# data.loc[not data["a"]]   # ValueError at runtime

An option to avoid this false-positive would be to ignore != "" comparisons when they are inside [ ].

edit: or nudge people to data.loc[data["a"].ne("")]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant