Can Python's Pandera validate whether a Geopandas DataFrame has Linestrings

60 views Asked by At

Is there a way to check data types other than the standard built in data types (str, float, int)? I tried the following, but that results in an error, because the data type LineString is unknown to Pandera. Any suggestions?

import pandera as pa
from shapely.geometry import LineString


class Schema(pa.DataFrameModel:
   id: int = pa.Field(unique=True, nullable=False)
   geometry: LineString = pa.Field(nullable=False)



try:
    Schema.validate(some_df, lazy=True)
except pa.errors.SchemaErrors as err:
    errors = err.failure_cases
    error_data = err.data

pandera extensions as a possibility? How to implement then?

0

There are 0 answers