Giter Site home page Giter Site logo

Comments (5)

shawnbrown avatar shawnbrown commented on July 27, 2024

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.

upretip avatar upretip commented on July 27, 2024

Thanks. I will follow this.

from datatest.

shawnbrown avatar shawnbrown commented on July 27, 2024

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.

shawnbrown avatar shawnbrown commented on July 27, 2024

@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.

upretip avatar upretip commented on July 27, 2024

Thanks for the help. Closing this issue now!

from datatest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.