Replies: 5 comments
-
You need to import from pandera.polars import DataFrameModel, Field
from pandera.typing import Series
from pandera.engines.polars_engine import Time
# from polars import Time
class TimeDataModel(DataFrameModel):
time: Series[Time] = Field(nullable=False, coerce=True)
if __name__ == "__main__":
TimeDataModel.to_schema() |
Beta Was this translation helpful? Give feedback.
-
@ksolarski thanks for replying I was testing the workaround you gave me, but I couldn't make it work on my project, it was practically imploding, so I decided to try it independently. This is the test file from pandera.polars import DataFrameModel, Field
from pandera.typing import Series
from pandera.engines.polars_engine import Time
from pandas import DataFrame
class TestDataFrame(DataFrameModel):
time: Series[Time] = Field(nullable=False, coerce=False)
# time: Series[Time] = Field(nullable=False, coerce=True)
if __name__ == '__main__':
test_data: DataFrame = DataFrame({
"time": ["10:00", "11:00", "12:00", "13:00"]
})
TestDataFrame.validate(test_data, lazy=True) And this is the error I get
Also tried to update the libraries in case I was missing something crucial, but the result is the same. I'm working with
|
Beta Was this translation helpful? Give feedback.
-
You are trying to use from pandera.polars import DataFrameModel, Field
from pandera.typing import Series
from pandera.engines.polars_engine import Time
from datetime import time
from polars import DataFrame
class TestDataFrame(DataFrameModel):
time: Series[Time] = Field(nullable=False, coerce=False)
test_data: DataFrame = DataFrame(
{"time": [time(10, 00), time(11, 00), time(12, 00), time(13, 00)]},
)
TestDataFrame.validate(test_data, lazy=True) |
Beta Was this translation helpful? Give feedback.
-
That did the trick, thanks for the insight I was using Pandas to read the file, gather the data and apply the validations using the data frame schema. Since everything was working so far, I thought the Thanks again, cheers |
Beta Was this translation helpful? Give feedback.
-
Closing issue, looks like this is addressed |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
Got the error
TypeError: Data type 'Time' not understood by Engine.
when I tried to usepolars.Time
as a Data Type on aDataFrameModel
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Expected behavior
Given that
Time
is inside the supported Data Types, it should work as intended like any other type.Desktop (please complete the following information):
Additional info
Error when using
pandera.engines.polars_engine.Time
:Error when using
polars.Time
:Beta Was this translation helpful? Give feedback.
All reactions