-
-
Notifications
You must be signed in to change notification settings - Fork 361
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
pandera.io.from_frictionless_schema throws an error when reading a frictionless schema in pandera==0.23.1 and frictionless==5.18.1
- [ 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.
- [ x ] (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
import frictionless
import pandera
from pandera.io import from_frictionless_schema
example_schema = frictionless.Schema.from_descriptor(
{
"fields": [
{"name": "id", "type": "string", "description":"My Id", "constrains" : {"unique":True}},
]
}
)
example_schema.to_yaml("example_schema.yaml")
from_frictionless_schema("example_schema.yaml").columns["osm_id"].uniquethrows
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[4], line 9
1 example_schema = frictionless.Schema.from_descriptor(
2 {
3 "fields": [
(...) 6 }
7 )
8 example_schema.to_yaml("example_schema.yaml")
----> 9 from_frictionless_schema("example_schema.yaml").columns["osm_id"].unique
File ~/issues/pandera/pandera/io/pandas_io.py:854, in from_frictionless_schema(schema)
849 if not isinstance(schema, FrictionlessSchema):
850 schema = FrictionlessSchema(schema)
852 assembled_schema = {
853 "columns": {
--> 854 field.name: FrictionlessFieldParser(
855 field, schema.primary_key
856 ).to_pandera_column()
857 for field in schema.fields
858 },
859 "index": None,
860 "checks": None,
861 "coerce": True,
862 "strict": True,
863 # only set dataframe-level uniqueness if the frictionless primary
864 # key property specifies more than one field
865 "unique": (
866 None if len(schema.primary_key) == 1 else list(schema.primary_key)
867 ),
868 }
869 return deserialize_schema(assembled_schema)
File ~/issues/pandera/pandera/io/pandas_io.py:649, in FrictionlessFieldParser.__init__(self, field, primary_keys)
647 self.primary_keys = primary_keys
648 self.name = field.name
--> 649 self.type = field.get("type", "string")
AttributeError: 'StringField' object has no attribute 'get'
Expected behavior
No error
I know what to change to solve the issue, I will make a PR
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working