datetime_nan_data_check

Data check that checks each column in the input for datetime features and will issue an error if NaN values are present.

Module Contents

Classes Summary

DateTimeNaNDataCheck

Check each column in the input for datetime features and will issue an error if NaN values are present.

Attributes Summary

error_contains_nan

Contents

class evalml.data_checks.datetime_nan_data_check.DateTimeNaNDataCheck[source]

Check each column in the input for datetime features and will issue an error if NaN values are present.

Methods

name

Return a name describing the data check.

validate

Check if any datetime columns contain NaN values.

name(cls)

Return a name describing the data check.

validate(self, X, y=None)[source]

Check if any datetime columns contain NaN values.

Parameters
  • X (pd.DataFrame, np.ndarray) – Features.

  • y (pd.Series, np.ndarray) – Ignored. Defaults to None.

Returns

dict with a DataCheckError if NaN values are present in datetime columns.

Return type

dict

Example

>>> import pandas as pd
>>> import woodwork as ww
>>> import numpy as np
>>> dates = np.arange(np.datetime64('2017-01-01'), np.datetime64('2017-01-08'))
>>> dates[0] = np.datetime64('NaT')
>>> df = pd.DataFrame(dates, columns=['index'])
>>> df.ww.init()
>>> dt_nan_check = DateTimeNaNDataCheck()
>>> assert dt_nan_check.validate(df) == {"warnings": [],
...                                             "actions": [],
...                                             "errors": [DataCheckError(message='Input datetime column(s) (index) contains NaN values. Please impute NaN values or drop these rows or columns.',
...                                                                     data_check_name=DateTimeNaNDataCheck.name,
...                                                                     message_code=DataCheckMessageCode.DATETIME_HAS_NAN,
...                                                                     details={"columns": ['index'], "rows": None}).to_dict()]}
evalml.data_checks.datetime_nan_data_check.error_contains_nan = Input datetime column(s) ({}) contains NaN values. Please impute NaN values or drop these rows...