Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchemaModel does not support empty data type #522

Closed
2 tasks done
jeffzi opened this issue Jun 23, 2021 · 3 comments
Closed
2 tasks done

SchemaModel does not support empty data type #522

jeffzi opened this issue Jun 23, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@jeffzi
Copy link
Collaborator

jeffzi commented Jun 23, 2021

SchemaModel does not support annotations without a data type, which is supported by DataFrameSchema.

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandera.

Code Sample, a copy-pastable example

import pandera as pa

pa.DataFrameSchema({"a": pa.Column()})  # works
#> <Schema DataFrameSchema(columns={'a': <Schema Column(name=a, type=None)>}, checks=[], index=None, coerce=False, pandas_dtype=None,strict=False,name=None,ordered=False)>


class Schema(pa.SchemaModel):
    column_a: pa.typing.Series


Schema.to_schema()
#> Traceback (most recent call last):
#> <ipython-input-6-87d3c11c1990> in <module>
#> ----> 1 Schema.to_schema()
#> XX/pandera/pandera/model.py in to_schema(cls)
#>     195         cls.__dataframe_checks__ = df_custom_checks + df_registered_checks
#>     196 
#> --> 197         columns, index = cls._build_columns_index(
#>     198             cls.__fields__, cls.__checks__, **mi_kwargs
#>     199         )
#> ~XX/model.py in _build_columns_index(cls, fields, checks, **multiindex_kwargs)
#>     319                 indices.append(index)
#>     320             else:
#> --> 321                 raise SchemaInitError(
#>     322                     f"Invalid annotation '{field_name}: {annotation.raw_annotation}'"
#>     323                 )
#> SchemaInitError: Invalid annotation 'column_a: <class 'pandera.typing.Series'>'

Expected behavior

SchemaModel should match the DataFrameSchema API and the data type should be optional.

@jeffzi jeffzi added the bug Something isn't working label Jun 23, 2021
@jeffzi jeffzi self-assigned this Jun 23, 2021
@cosmicBboy
Copy link
Collaborator

hey @jeffzi I don't think this addresses the question in #521... tho I think it would be a nice feature to have, so feel free to make a PR for it!

@cosmicBboy
Copy link
Collaborator

@jeffzi FYI #594 added support for the any type, it probably still makes sense to support an empty pa.typing.Series type, so this issue is still valid

@jeffzi
Copy link
Collaborator Author

jeffzi commented Sep 23, 2021

Fixed by #602

@jeffzi jeffzi closed this as completed Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants