Giter Site home page Giter Site logo

Comments (3)

cosmicBboy avatar cosmicBboy commented on June 19, 2024

Hi @miguel-mi-silva if you're using DataFrameModels you should use pa.check_types

@check_types
def process(df: TypeDataFrame[InputSchema]) -> TypeDataFrame[OutputSchema]:
    return df.assign(c="c")

check_input and check_output are for DataFrameSchemas

from pandera.

miguel-mi-silva avatar miguel-mi-silva commented on June 19, 2024

Hi @miguel-mi-silva if you're using DataFrameModels you should use pa.check_types

@check_types
def process(df: TypeDataFrame[InputSchema]) -> TypeDataFrame[OutputSchema]:
    return df.assign(c="c")

check_input and check_output are for DataFrameSchemas

Thanks for that. However, even with those changes, the error on the return type Incompatible return value type (got "pandas.core.frame.DataFrame", expected "pandera.typing.pandas.DataFrame[OutputSchema]") [return-value] still exists. Is that a known issue or am I doing something wrong?

Here's the new code to facilitate:

from pandera import SchemaModel, check_types
from pandas import DataFrame
from pandera.typing import DataFrame as TypeDataFrame


class InputSchema(SchemaModel):
    a: int
    b: bool

class OutputSchema(SchemaModel):
    a: int
    b: bool
    c: str

df = DataFrame({"a": [1], "b": [True]})

@check_types
def process(df: TypeDataFrame[InputSchema]) -> TypeDataFrame[OutputSchema]:
    return df.assign(c="c")

from pandera.

cosmicBboy avatar cosmicBboy commented on June 19, 2024

What does your mypy config look like?

See the docs for a discussion on mypy support. If you care about type lints there's some guidance there on how to make you mypy linting pass, e.g.

@check_types
def process(df: TypeDataFrame[InputSchema]) -> TypeDataFrame[OutputSchema]:
    return df.assign(c="c").pipe(TypeDataFrame[OutputSchema])

or

from typing import cast

@check_types
def process(df: TypeDataFrame[InputSchema]) -> TypeDataFrame[OutputSchema]:
    return cast(TypeDataFrame[OutputSchema], df.assign(c="c"))

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.