Skip to content

Parser not invoked when coerce = True #2129

@JungeWerther

Description

@JungeWerther

Describe the bug
A clear and concise description of what the bug is.

  • [ x] I have checked that this issue has not already been reported.
  • [ x] I have confirmed this bug exists on the latest version of pandera.
  • (optional) I have confirmed this bug exists on the main branch of pandera.

Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

class A(pa.pandas.DataFrameModel):
     c: float = pa.pandas.Field(alias="B", coerce=True) 
     @pa.pandas.parser("B")
     my_parser(cls, series: pd.Series) -> Series:
          assert False
          return series

Expected behavior

Above code never invokes my_parser since coerce=True. However the parser can perform effects or manipulations that are independent of the typecast presumed by coerce=True. If coercion is a special case of parsing, then I would expect the parser to take precedence of the coerce flag, instead of the other way around.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions