def _sqlalchemy(cls, column, value_set, parse_strings_as_datetimes, **kwargs): if parse_strings_as_datetimes: parsed_value_set = parse_value_set(value_set) else: parsed_value_set = value_set return column.notin_(tuple(parsed_value_set))
def _validate( self, configuration: ExpectationConfiguration, metrics: Dict, runtime_configuration: dict = None, execution_engine: ExecutionEngine = None, ): parse_strings_as_datetimes = self.get_success_kwargs(configuration).get( "parse_strings_as_datetimes" ) observed_value_counts = metrics.get("column.value_counts") observed_value_set = set(observed_value_counts.index) value_set = self.get_success_kwargs(configuration).get("value_set") or [] if parse_strings_as_datetimes: parsed_value_set = parse_value_set(value_set) else: parsed_value_set = value_set expected_value_set = set(parsed_value_set) if not expected_value_set: success = True else: success = observed_value_set.issubset(expected_value_set) return { "success": success, "result": { "observed_value": sorted(list(observed_value_set)), "details": {"value_counts": observed_value_counts}, }, }
def _pandas( cls, column, value_set, **kwargs, ): # no need to parse as datetime; just compare the strings as is parse_strings_as_datetimes: bool = ( kwargs.get("parse_strings_as_datetimes") or False ) if parse_strings_as_datetimes: # deprecated-v0.13.41 warnings.warn( """The parameter "parse_strings_as_datetimes" is deprecated as of v0.13.41 in \ v0.16. As part of the V3 API transition, we've moved away from input transformation. For more information, \ please see: https://greatexpectations.io/blog/why_we_dont_do_transformations_for_expectations/ """, DeprecationWarning, ) if value_set is None: # Vacuously true return np.ones(len(column), dtype=np.bool_) if pd.api.types.is_datetime64_any_dtype(column): parsed_value_set = parse_value_set(value_set=value_set) else: parsed_value_set = value_set return ~column.isin(parsed_value_set)
def _pandas( cls, column, value_set, **kwargs, ): # no need to parse as datetime; just compare the strings as is parse_strings_as_datetimes: bool = ( kwargs.get("parse_strings_as_datetimes") or False) if parse_strings_as_datetimes: warnings.warn( f"""The parameter "parse_strings_as_datetimes" is no longer supported and will be deprecated in a \ future release. Please update code accordingly. Moreover, in "{cls.__name__}._pandas()", it is not used. """, DeprecationWarning, ) if value_set is None: # Vacuously true return np.ones(len(column), dtype=np.bool_) if pd.api.types.is_datetime64_any_dtype(column): parsed_value_set = parse_value_set(value_set=value_set) else: parsed_value_set = value_set return ~column.isin(parsed_value_set)
def _pandas(cls, column, value_set, **kwargs): if value_set is None: # Vacuously true return np.ones(len(column), dtype=np.bool_) if pd.api.types.is_datetime64_any_dtype(column): parsed_value_set = parse_value_set(value_set=value_set) else: parsed_value_set = value_set return ~column.isin(parsed_value_set)
def _validate( self, configuration: ExpectationConfiguration, metrics: Dict, runtime_configuration: dict = None, execution_engine: ExecutionEngine = None, ): parse_strings_as_datetimes = self.get_success_kwargs( configuration).get("parse_strings_as_datetimes") observed_value_counts = metrics.get("column.value_counts") value_set = self.get_success_kwargs(configuration).get("value_set") if parse_strings_as_datetimes: # deprecated-v0.13.41 warnings.warn( """The parameter "parse_strings_as_datetimes" is deprecated as of v0.13.41 in \ v0.16. As part of the V3 API transition, we've moved away from input transformation. For more information, \ please see: https://greatexpectations.io/blog/why_we_dont_do_transformations_for_expectations/ """, DeprecationWarning, ) parsed_value_set = parse_value_set(value_set) observed_value_counts.index = pd.to_datetime( observed_value_counts.index) else: parsed_value_set = value_set observed_value_set = set(observed_value_counts.index) expected_value_set = set(parsed_value_set) return { "success": observed_value_set.issuperset(expected_value_set), "result": { "observed_value": sorted(list(observed_value_set)), "details": { "value_counts": observed_value_counts }, }, }
def _validate( self, configuration: ExpectationConfiguration, metrics: Dict, runtime_configuration: dict = None, execution_engine: ExecutionEngine = None, ): parse_strings_as_datetimes = self.get_success_kwargs( configuration).get("parse_strings_as_datetimes") observed_value_counts = metrics.get("column.value_counts") value_set = self.get_success_kwargs(configuration).get("value_set") if parse_strings_as_datetimes: warnings.warn( """The parameter "parse_strings_as_datetimes" is no longer supported and will be deprecated in a \ future release. Please update code accordingly. """, DeprecationWarning, ) parsed_value_set = parse_value_set(value_set) observed_value_counts.index = pd.to_datetime( observed_value_counts.index) else: parsed_value_set = value_set observed_value_set = set(observed_value_counts.index) expected_value_set = set(parsed_value_set) return { "success": observed_value_set.issuperset(expected_value_set), "result": { "observed_value": sorted(list(observed_value_set)), "details": { "value_counts": observed_value_counts }, }, }