def test_datetime_transform(datetimes): datetime = Datetime() for series in datetimes: assert str(series.dtype) == "object" transform = datetime.transform(series) assert str(transform.dtype) == "datetime64[ns]" assert datetime.datetime_format is not None
def test_datetime_coerce_user_format(): datetime = Datetime(datetime_format="%m/%d/%Y") dates = pd.Series(["01/01/2017"] * 2 + ["13/12/2017"], name="dates") warning = ( "Some rows in series 'dates' are incompatible with datetime format " "'%m/%d/%Y' and have been replaced with null values. You may be able " "to fix this by using an instantiated Datetime logical type with a different " "format string specified for this column during Woodwork initialization." ) with pytest.warns(TypeConversionWarning, match=warning): transformed = datetime.transform(dates) assert str(transformed.dtype) == "datetime64[ns]" assert transformed[2] is pd.NaT assert datetime.datetime_format == "%m/%d/%Y"