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

Add default column value param #1136

Merged
merged 12 commits into from
Apr 17, 2023
Merged

Add default column value param #1136

merged 12 commits into from
Apr 17, 2023

Conversation

kykyi
Copy link
Contributor

@kykyi kykyi commented Mar 22, 2023

In relation to #502, this PR (and this fork) introduces a default value using pandas.fillna()! When building Columns in a DataFrameSchema, you can add a default argument to fill NaNs in dataframe being validated:

>>> df = pd.DataFrame({"some_col": [None]})
>>> df
    some_col
0  None
>>> schema = DataFrameSchema(columns={"some_col": Column(str, default="the default value")})
>>> df = schema.validate(df)
>>> df
    some_col
0  the default value
>>> 🚀 

This PR includes the updated code, tests to assert default works as expected, and adds docstrings in line with the rest of the codebase.

TODO:

  • Linting? Confirm what standards are used 💅
  • Approval! Ensure this PR covers the full scope ✅

@kykyi kykyi marked this pull request as draft March 22, 2023 20:20
@kykyi kykyi changed the title Add default column value option Add default column value param Mar 22, 2023
@cosmicBboy
Copy link
Collaborator

looks like there are some mypy errors and unit test errors.

Be sure to setup and run pre-commit and run unit tests to make sure things are running locally!

@cosmicBboy
Copy link
Collaborator

taking a look now @kykyi! gonna help out with the conflicts

@cosmicBboy cosmicBboy marked this pull request as ready for review April 14, 2023 14:16
Signed-off-by: Niels Bantilan <[email protected]>
@codecov
Copy link

codecov bot commented Apr 14, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (c9e7a6e) 97.37% compared to head (e66abbd) 97.37%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1136   +/-   ##
=======================================
  Coverage   97.37%   97.37%           
=======================================
  Files          65       65           
  Lines        4912     4916    +4     
=======================================
+ Hits         4783     4787    +4     
  Misses        129      129           
Impacted Files Coverage Δ
pandera/api/pandas/components.py 99.11% <ø> (ø)
pandera/api/pandas/container.py 99.25% <ø> (ø)
pandera/api/pandas/model_components.py 100.00% <ø> (ø)
pandera/backends/pandas/components.py 96.66% <ø> (ø)
pandera/api/base/model_components.py 90.56% <100.00%> (+0.18%) ⬆️
pandera/api/pandas/array.py 100.00% <100.00%> (ø)
pandera/backends/pandas/array.py 98.14% <100.00%> (+0.03%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kykyi
Copy link
Contributor Author

kykyi commented Apr 16, 2023

Thanks @cosmicBboy 👌 🙌

Anything else needed on this PR now?

Copy link
Collaborator

@cosmicBboy cosmicBboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@cosmicBboy
Copy link
Collaborator

Anything else needed on this PR now?

Nope, ready to merge! thanks for the contribution @kykyi , and congrats on your first PR to pandera!

@kykyi
Copy link
Contributor Author

kykyi commented Apr 17, 2023

Great thanks for all your help 😄😄

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