evalml.data_checks.DateTimeNaNDataCheck.validate

DateTimeNaNDataCheck.validate(X, y=None)[source]

Checks if any datetime columns contain NaN values.

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

  • y (ww.DataColumn, 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')
>>> ww_input = ww.DataTable(pd.DataFrame(dates, columns=['index']))
>>> dt_nan_check = DateTimeNaNDataCheck()
>>> assert dt_nan_check.validate(ww_input) == {"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'}).to_dict()]}