You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import numpy as np
import pandas as pd
import pandera as pa
from pandera import Check, Column
class RawSignal:
# columns name (for type hints only)
id = "id"
amplitude = "amplitude"
frequency = "frequency"
phase = "phase"
offset = "offset"
mu = "mu"
sigma = "sigma"
signal = "signal"
n_samples = "n_samples"
# class schema to enforce datatype, value range and nullability
schema = pa.DataFrameSchema(
{
id: Column(int, [Check.greater_than_or_equal_to(0)],
nullable=False),
amplitude: Column(float, [Check.greater_than_or_equal_to(0)],
nullable=False),
frequency: Column(float, [Check.greater_than_or_equal_to(0)],
nullable=False),
phase: Column(float, [Check.greater_than_or_equal_to(0),
Check.less_than_or_equal_to(2 * np.pi)],
nullable=False),
offset: Column(float, nullable=False),
mu: Column(float, nullable=False),
sigma: Column(float, [Check.greater_than_or_equal_to(0)],
nullable=False),
n_samples: Column(int, [Check.greater_than_or_equal_to(0)],
nullable=False),
signal: Column(object,
nullable=False),
},
strict=True
)
The column "signal" should contain list[float]. How do I enforce this in the schema ? I am currently setting the dtype as "object".
I've tried using a custom check with a lambda function on isinstance(x, list) to no avail.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I am running the current schema:
The column "signal" should contain list[float]. How do I enforce this in the schema ? I am currently setting the dtype as "object".
I've tried using a custom check with a lambda function on isinstance(x, list) to no avail.
Beta Was this translation helpful? Give feedback.
All reactions