Skip to content

Commit

Permalink
remove redundant assertion, np.any(np.isnat()) check and object check
Browse files Browse the repository at this point in the history
  • Loading branch information
galipremsagar committed Mar 17, 2020
1 parent e317a5c commit 0279efd
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 0279efd

Please sign in to comment.