From 0279efd9edcd325a5cd4f6b2ba7a8da6f53df296 Mon Sep 17 00:00:00 2001 From: galipremsagar Date: Tue, 17 Mar 2020 08:25:19 -0700 Subject: [PATCH] remove redundant assertion, np.any(np.isnat()) check and object check --- python/cudf/cudf/core/column/column.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) 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 )