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

ignore_nan for distinctvalues #37

Closed
wants to merge 2 commits into from
Closed

ignore_nan for distinctvalues #37

wants to merge 2 commits into from

Conversation

Maarten-vd-Sande
Copy link

Thanks for the great tool! 👋

Small & self-explanatory PR.

I added an argument to IsDistinctValidation called ignore_nan which when set to True does not take NaN values along when checking for duplicates.

Let me know if it needs extra work somewhere.

@multimeric
Copy link
Owner

Hi, can you first please check if allow_empty solves this use-case?

@Maarten-vd-Sande
Copy link
Author

That seems to work, I saw #13 but somehow I thought it didn't work for me. Now when I check again it does seem to work just fine.

Thanks for your fast reply!

proof:

df = pd.DataFrame({'C1': {'A': 5, 'B': 2, 'C': 3},
                   'C2': {'C': 4, 'D': 2},
                   'C3': {'A': 3, 'B': 4, 'C': 6, 'D': 8}})

print(df)
schema = Schema([
    Column('C1', [IsDistinctValidation()], allow_empty=True),
    Column('C2', [IsDistinctValidation()], allow_empty=True),
    Column('C3', [IsDistinctValidation()], allow_empty=True)
])

for error in schema.validate(df):
    print(error)
    C1   C2  C3
A  5.0  NaN   3
B  2.0  NaN   4
C  3.0  4.0   6
D  NaN  2.0   8

[ no errors printed]

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 this pull request may close these issues.

2 participants