Expect a column to contain values of a specified data type.
expect_column_values_to_be_of_type
This expectation level is EXPERIMENTAL
Contributors:
Tags:
Metrics:
Description
Expect a column to contain values of a specified data type.
expect_column_values_to_be_of_type is a Column Map Expectation for typed-column backends, and also for PandasDataset where the column dtype and provided type_ are unambiguous constraints (any dtype except 'object' or dtype of 'object' with type_ specified as 'object').
For PandasDataset columns with dtype of 'object' expect_column_values_to_be_of_type will
independently check each row's type.
Args:
- column (str): The column name.
- type_ (str): A string representing the data type that each column should have as entries. Valid types are defined by the current backend implementation and are dynamically loaded. For example, valid types for PandasDataset include any numpy dtype values (such as 'int64') or native python types (such as 'int'), whereas valid types for a SqlAlchemyDataset include types named by the current driver such as 'INTEGER' in most SQL dialects and 'TEXT' in dialects such as postgresql. Valid types for SparkDFDataset include 'StringType', 'BooleanType' and other pyspark-defined type names. Note that the strings representing these types are sometimes case-sensitive. For instance, with a Pandas backend
timestamp
will be unrecognized and
fail the expectation, whileTimestamp
would pass with valid data.
Keyword Args:
- mostly (None or a float between 0 and 1): Successful if at least mostly fraction of values match the expectation. For more detail, see mostly.
Other Parameters:
- result_format (str or None): Which output mode to use: BOOLEAN_ONLY, BASIC, COMPLETE, or SUMMARY. For more detail, see result_format.
- include_config (boolean): If True, then include the expectation config as part of the result object.
- catch_exceptions (boolean or None): If True, then catch exceptions and include them as part of the result object. For more detail, see catch_exceptions.
- meta (dict or None): A JSON-serializable dictionary (nesting allowed) that will be included in the output without modification. For more detail, see meta.
Returns:
Exact fields vary depending on the values passed to result_format, include_config, catch_exceptions, and meta.
See also:
Want to make your own Expectation or an improvement to this one?
We've put together some great how to guides (including videos) on how to create your own expectations in a flash!
You can see those resources here: Contributor Resources