Giter VIP home page Giter VIP logo

Comments (2)

WilianZilv avatar WilianZilv commented on May 31, 2024

Digging deeper, i found that the problem is in the function "pydantic_validate" (pandera/typing/pandas) line: 240

try:
    valid_data = schema.validate(data)
except SchemaError as exc:
    raise ValueError(str(exc)) from exc

The issue is that it raises a simplified Exception with no context, pydantic raises a ValidationError.
I found that this little change in the code fixes de issue:

try:
    valid_data = schema.validate(data)
except SchemaError as exc:
    errors_ = ErrorWrapper(exc=exc, loc=exc.schema.name)
    raise ValidationError([errors_], DataFrame[T])

I'm not sure about the "DataFrame[T]" part, but its working.

now i'm getting a much more detailed error:

{'loc': ('body', 'customer_alias'), 'msg': ..., 'type': 'value_error.schema', 'ctx': {'schema': <Schema Column(name=customer_alias, type=DataType(str))>, 'data': ..., 'check': "dtype('str')", 'check_index': None, 'check_output': None, 'reason_code': <SchemaErrorReason.WRONG_DATATYPE: 'wrong_dtype'>}}

from pandera.

WilianZilv avatar WilianZilv commented on May 31, 2024

the solution i gave may not be correct for pydantic v2
my fastapi project is running pydantic==1.10.12, as pandera already uses pydantic==2.3.0

i think it needs some backwards compatibility.

i'm a bit confused, can someone help?

from pandera.

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.