Comments (5)
I've been looking at this closely and discovered a handful of un-handled corner cases related to NaN
values. Until I get this sorted, NaN
values will have to be handled using a workaround—e.g., using the fillna()
method to replace them with a proxy value.
As a stopgap, you could do the following:
NAN = object()
# Include NAN in the validation set.
data = df['A'].fillna(NAN)
validate.superset(data, {'x', 'y', 'z', NAN})
# Accept NAN as a difference.
data = df['A'].fillna(NAN)
with accepted(Invalid(NAN)):
validate(data, str)
Going forward, I will file a related issue/bug for this with the goal of allowing the use of NaN values directly:
# Include NaN in the validation set.
validate.superset(data, {'x', 'y', 'z', np.nan})
# Accept NAN as a difference.
with accepted(Invalid(np.nan)):
validate(data, str)
I'll post a follow-up to this issue once I have patched this behavior.
from datatest.
Thanks. I will follow this.
from datatest.
This is done:
ce71b34: Update predicate handling to better support NaN values.
bee6aa8: Add NaN handling idioms to test_usecases.py.
32d3bb9: Add test_numbers_equal() to verify numeric comparison.
e8435b1: Update difference behavior to support tuples containing NaNs.
c962e04: Change RequiredInterval to fail if arguments are NaN.
c78f390: Fix RequiredInterval to properly handle NaN differences.
4995510: Update NaN use cases to highlight recommended pattern.
fa2646e: Add how-to documentation for working with NaN values.
from datatest.
@upretip, I've just pushed some new "how to" docs that give detail regarding NaN validation and behavior. You can view it in the latest docs here:
How to Deal With NaN Values
https://datatest.readthedocs.io/en/latest/how-to/nan-values.html
from datatest.
Thanks for the help. Closing this issue now!
from datatest.
Related Issues (20)
- Fully Composable Allowances. HOT 1
- Simplified DataSource Loading. HOT 1
- Selector.load_data() silently fails on missing file. HOT 1
- pytest_runtest_makereport crashes on test exceptions HOT 2
- Add "How to Validate Inequalities" documentation.
- Add "How to Validate Counts and Cardinality" documentation.
- Change get_reader.from_excel() to accept keyword arguments HOT 1
- AcceptedExtra not working as expected with dicts HOT 3
- Squint objects not handled properly when used as requirements. HOT 1
- Crashes pytest-xdist processes (NOTE: See comments for fix.) HOT 3
- Investigate Support for DataFrame-Protocol
- Squint nested-mapping queries not handled properly with non-mapping requirements.
- NaT issue HOT 5
- Improve error message for @working_directory decorator
- Hey man! HOT 1
- Improve existing or create another Deviation-like difference
- Understanding Pandas validation HOT 1
- How to validate Pandas data type "Int64"?
- accepted.tolerance() not applied when comparing values in nested dictionary HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datatest.