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

Use verify_rows and verify_columns #48

Open
topper-123 opened this issue Sep 3, 2017 · 3 comments
Open

Use verify_rows and verify_columns #48

topper-123 opened this issue Sep 3, 2017 · 3 comments

Comments

@topper-123
Copy link
Contributor

Hi @TomAugspurger ,

Thanks for this great library, I use it a lot.

A lot of verification is done row-wise and/or column-wise. Engarde has some specific row/column functions, but I suggest adding functions that take generic functions that operate on rows/columns:

That means we can do something like this generically:

@verify_columns({'A': lambda col: col.sum() > 5})
@verify_rows(lambda row: row.A > row.B)
def add(df1, df2):
    return df1 + df2

This functionality would by default verify that all checks pass, but by setting how='any', we could also check that just any row/column pass the test (example: verify_rows(lambda row: row.A > row.B, how='any')).

Would you accept a pull request along these lines?

@TomAugspurger
Copy link
Collaborator

The current way of doing this would be with @verify_all

@verify_all(lambda df: df.A > df.B)
def add(df1, df2):
    return df1 + df2

Still, it'd probably be nice for condition functions that aren't vectorized, so yeah this seems sensible.

by setting how='any', we could also check that just any row/column pass the test

I'd prefer separate functions like verify_rows_all and verify_rows_any. I try to avoid using keyword arguments in functions that also take **kwargs, since you can have conflicts between which function that keyword applies to.

@topper-123
Copy link
Contributor Author

I looked into this again tonight.

I've made an implementation locally, but it's different than my Github fork of engarde, and I'd like to keep that. Do you happen to know if I can upload a pull request to your repository without deleting my fork?

@TomAugspurger
Copy link
Collaborator

TomAugspurger commented Sep 14, 2017 via email

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

No branches or pull requests

2 participants