diff --git a/python/cudf/cudf/tests/test_dataframe.py b/python/cudf/cudf/tests/test_dataframe.py index 9acf6783095..b63739a0915 100644 --- a/python/cudf/cudf/tests/test_dataframe.py +++ b/python/cudf/cudf/tests/test_dataframe.py @@ -5054,6 +5054,18 @@ def test_insert(data): assert_eq(pdf, gdf) +@pytest.mark.parametrize( + "data", [{"A": [1, 2, 3], "B": ["a", "b", "c"]}], +) +def test_insert_NA(data): + pdf = pd.DataFrame.from_dict(data) + gdf = cudf.DataFrame.from_pandas(pdf) + + pdf["C"] = pd.NA + gdf["C"] = cudf.NA + assert_eq(pdf, gdf) + + def test_cov(): gdf = cudf.datasets.randomdata(10) pdf = gdf.to_pandas() diff --git a/python/cudf/cudf/utils/utils.py b/python/cudf/cudf/utils/utils.py index 209f61ad399..1293122c31a 100644 --- a/python/cudf/cudf/utils/utils.py +++ b/python/cudf/cudf/utils/utils.py @@ -42,10 +42,7 @@ def scalar_broadcast_to(scalar, size, dtype=None): if isinstance(size, (tuple, list)): size = size[0] - if scalar is None or ( - isinstance(scalar, (np.datetime64, np.timedelta64)) - and np.isnat(scalar) - ): + if cudf._lib.scalar._is_null_host_scalar(scalar): if dtype is None: dtype = "object" return column.column_empty(size, dtype=dtype, masked=True)