Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Validation Failure when Schema Contains Column with Empty List of Validations Objects #63

Description

@lguntde

I built a schema based on the list of columns I knew my DataFrame would contain. An number of these don't require validation beyond a check that they exist in the DataFrame (example: column containing comment field of unspecified format). I built a schema wherein I specified these columns as follows:

schema = Schema([
... ,
Column('name',[]),
...
])

I then ran schema.validate(df) and received the following error:

Exception has occurred: AttributeError
'str' object has no attribute 'get_errors'

This traces back to:
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas_schema/column.py", line 27, in
return [error for validation in self.validations for error in validation.get_errors(series, self)]

Since the column instance in question has no validations to iterate over, it makes sense, that this would fail.

My suggestion would be to include a check in the code that simply returns [] if no validations are present.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions