Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _vectorized_check(self, parent_schema, check_index, check_obj):
"""Perform a vectorized check on a series.
:param parent_schema: The schema object that is being checked and that
was inherited from the parent class.
:param check_index: The validator to check the series for
:param dict check_obj: a dictionary of pd.Series to be used by
`_check_fn` and `_vectorized_series_check`
"""
val_result = self.fn(check_obj)
if isinstance(val_result, pd.Series):
if not val_result.dtype == PandasDtype.Bool.value:
raise TypeError(
"validator %d: %s must return bool or Series of type "
"bool, found %s" %
(check_index, self.fn.__name__, val_result.dtype))
if val_result.all():
return True
elif isinstance(check_obj, dict) or \
check_obj.shape[0] != val_result.shape[0] or \
(check_obj.index != val_result.index).all():
raise SchemaError(
self.generic_error_message(parent_schema, check_index))
else:
raise SchemaError(self.vectorized_error_message(
parent_schema, check_index, check_obj[~val_result]))
else:
if val_result:
pass
class PandasDtype(Enum):
Bool = "bool"
DateTime = "datetime64[ns]"
Category = "category"
Float = "float64"
Int = "int64"
Object = "object"
String = "object"
Timedelta = "timedelta64[ns]"
Bool = PandasDtype.Bool
DateTime = PandasDtype.DateTime
Category = PandasDtype.Category
Float = PandasDtype.Float
Int = PandasDtype.Int
Object = PandasDtype.Object
String = PandasDtype.String
Timedelta = PandasDtype.Timedelta
N_FAILURE_CASES = 10
class Check(object):
def __init__(
self,
fn,
groups=None,
class PandasDtype(Enum):
Bool = "bool"
DateTime = "datetime64[ns]"
Category = "category"
Float = "float64"
Int = "int64"
Object = "object"
String = "object"
Timedelta = "timedelta64[ns]"
Bool = PandasDtype.Bool
DateTime = PandasDtype.DateTime
Category = PandasDtype.Category
Float = PandasDtype.Float
Int = PandasDtype.Int
Object = PandasDtype.Object
String = PandasDtype.String
Timedelta = PandasDtype.Timedelta
N_FAILURE_CASES = 10
class Check(object):
def __init__(
self,
fn,
groups=None,
groupby=None,
element_wise=False,
error=None,
class PandasDtype(Enum):
Bool = "bool"
DateTime = "datetime64[ns]"
Category = "category"
Float = "float64"
Int = "int64"
Object = "object"
String = "object"
Timedelta = "timedelta64[ns]"
Bool = PandasDtype.Bool
DateTime = PandasDtype.DateTime
Category = PandasDtype.Category
Float = PandasDtype.Float
Int = PandasDtype.Int
Object = PandasDtype.Object
String = PandasDtype.String
Timedelta = PandasDtype.Timedelta
N_FAILURE_CASES = 10
class Check(object):
def __init__(
self,
fn,
groups=None,
groupby=None,
element_wise=False,
def __repr__(self):
if isinstance(self._pandas_dtype, PandasDtype):
dtype = self._pandas_dtype.value
else:
dtype = self._pandas_dtype
return "" % (self._name, dtype)
Bool = "bool"
DateTime = "datetime64[ns]"
Category = "category"
Float = "float64"
Int = "int64"
Object = "object"
String = "object"
Timedelta = "timedelta64[ns]"
Bool = PandasDtype.Bool
DateTime = PandasDtype.DateTime
Category = PandasDtype.Category
Float = PandasDtype.Float
Int = PandasDtype.Int
Object = PandasDtype.Object
String = PandasDtype.String
Timedelta = PandasDtype.Timedelta
N_FAILURE_CASES = 10
class Check(object):
def __init__(
self,
fn,
groups=None,
groupby=None,
element_wise=False,
error=None,
n_failure_cases=N_FAILURE_CASES):
Category = "category"
Float = "float64"
Int = "int64"
Object = "object"
String = "object"
Timedelta = "timedelta64[ns]"
Bool = PandasDtype.Bool
DateTime = PandasDtype.DateTime
Category = PandasDtype.Category
Float = PandasDtype.Float
Int = PandasDtype.Int
Object = PandasDtype.Object
String = PandasDtype.String
Timedelta = PandasDtype.Timedelta
N_FAILURE_CASES = 10
class Check(object):
def __init__(
self,
fn,
groups=None,
groupby=None,
element_wise=False,
error=None,
n_failure_cases=N_FAILURE_CASES):
"""Check object applies function element-wise or series-wise
class PandasDtype(Enum):
Bool = "bool"
DateTime = "datetime64[ns]"
Category = "category"
Float = "float64"
Int = "int64"
Object = "object"
String = "object"
Timedelta = "timedelta64[ns]"
Bool = PandasDtype.Bool
DateTime = PandasDtype.DateTime
Category = PandasDtype.Category
Float = PandasDtype.Float
Int = PandasDtype.Int
Object = PandasDtype.Object
String = PandasDtype.String
Timedelta = PandasDtype.Timedelta
N_FAILURE_CASES = 10
class Check(object):
def __init__(
self,
fn,
groups=None,
groupby=None,
DateTime = "datetime64[ns]"
Category = "category"
Float = "float64"
Int = "int64"
Object = "object"
String = "object"
Timedelta = "timedelta64[ns]"
Bool = PandasDtype.Bool
DateTime = PandasDtype.DateTime
Category = PandasDtype.Category
Float = PandasDtype.Float
Int = PandasDtype.Int
Object = PandasDtype.Object
String = PandasDtype.String
Timedelta = PandasDtype.Timedelta
N_FAILURE_CASES = 10
class Check(object):
def __init__(
self,
fn,
groups=None,
groupby=None,
element_wise=False,
error=None,
n_failure_cases=N_FAILURE_CASES):
"""Check object applies function element-wise or series-wise