diff --git a/python/cudf/cudf/core/column/column.py b/python/cudf/cudf/core/column/column.py index 3b9f917ce8c..bf84b83a5dc 100644 --- a/python/cudf/cudf/core/column/column.py +++ b/python/cudf/cudf/core/column/column.py @@ -1346,24 +1346,16 @@ def as_column(arbitrary, nan_as_null=None, dtype=None, length=None): arbitrary = arbitrary.astype(dtype) if arb_dtype.kind == "M": - import datetime as dt time_unit, _ = np.datetime_data(arbitrary.dtype) - cast_dtype = time_unit in ("D", "W", "M", "Y") or ( - len(arbitrary) > 0 - and ( - isinstance(arbitrary[0], str) - or isinstance(arbitrary[0], dt.datetime) - ) - ) + cast_dtype = time_unit in ("D", "W", "M", "Y") if cast_dtype: arbitrary = arbitrary.astype(np.dtype("datetime64[s]")) - assert arbitrary.dtype.itemsize == 8 buffer = Buffer(arbitrary) mask = None - if np.any(np.isnat(arbitrary)) or nan_as_null: + if nan_as_null: data = as_column( buffer, dtype=arbitrary.dtype, nan_as_null=nan_as_null )