unionai-oss / pandera

A light-weight, flexible, and expressive statistical data testing library
https://www.union.ai/pandera
MIT License
3.34k stars 308 forks source link

frictionless schema object has no attribute 'get' #1148

Open leandrocaldas opened 1 year ago

leandrocaldas commented 1 year ago

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

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

Code Sample, a copy-pastable example

# Your code here
from pandera.io import from_frictionless_schema
       FRICTIONLESS_SCHEMA = {
                "fields": [
                {
                    "name": "column_1",
                    "type": "integer",
                    "constraints": {"minimum": 10, "maximum": 99}
                },
                {
                    "name": "column_2",
                    "type": "string",
                    "constraints": {"maxLength": 10, "pattern": "\S+"}
                },
            ],
                "primaryKey": "column_1"
            }
            schema = from_frictionless_schema(FRICTIONLESS_SCHEMA)

Expected behavior

I'm trying to convert a sample of frictionless to pandera schema, I'm using same as documentation example, but with no success. This is the log error

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 2, in <dictcomp>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandera/io/pandas_io.py", line 588, in __init__
    self.type = field.get("type", "string")
AttributeError: 'IntegerField' object has no attribute 'get'

Additional context

Add any other context about the problem here.

pscff commented 1 year ago

I am having similar issues. This seems to be related to the frictionless version you are using. For me, the following worked:

pip uninstall frictionless pip install frictionless<5.0.0

gecBurton commented 8 months ago

+1 on this issue please. The code/functionality is contradicted docstring https://github.com/unionai-oss/pandera/blob/731a11324d2bb606b31b7d0d5349440d56f1c1b8/pandera/io/pandas_io.py#L781