Skip to content
Closed
5 changes: 0 additions & 5 deletions python/cudf/dataframe/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,10 @@ def __init__(self, data, mask=None, null_count=None):
nnz = _gdf.count_nonzero_mask(self._mask.mem,
size=len(self))
null_count = len(self) - nnz
if null_count == 0:
self._mask = None
else:
null_count = 0

assert 0 <= null_count <= len(self)
if null_count == 0:
# Remove mask if null_count is zero
self._mask = None

self._null_count = null_count

Expand Down
17 changes: 13 additions & 4 deletions python/cudf/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from libgdf_cffi import ffi, libgdf
from librmm_cffi import librmm as rmm

from .utils import make_mask


class Groupby(object):
"""Groupby object returned by cudf.DataFrame.groupby().
Expand Down Expand Up @@ -109,11 +111,18 @@ def _apply_agg(self, agg_type, result, add_col_values,
out_col_values = ffi.NULL

if agg_type == "count":
out_col_agg_series = Series(
Buffer(rmm.device_array(col_agg.size, dtype=np.int64)))
out_col_agg_series = Series.from_masked_array(
data=rmm.device_array(col_agg.size, dtype=np.int64),
mask=make_mask(col_agg.size)
)
else:
out_col_agg_series = Series(Buffer(rmm.device_array(
col_agg.size, dtype=self._df[val_col]._column.data.dtype)))
out_col_agg_series = Series.from_masked_array(
data=rmm.device_array(
col_agg.size,
dtype=self._df[val_col]._column.data.dtype
),
mask=make_mask(col_agg.size)
)

out_col_agg = out_col_agg_series._column.cffi_view

Expand Down
10 changes: 6 additions & 4 deletions python/cudf/utils/cudautils.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def gpu_fill_value(data, value):
def fill_value(arr, value):
"""Fill *arr* with value
"""
gpu_fill_value.forall(arr.size)(arr, value)
if arr.size > 0:
gpu_fill_value.forall(arr.size)(arr, value)


@cuda.jit
Expand Down Expand Up @@ -373,9 +374,10 @@ def gpu_fill_masked(value, validity, out):

def fillna(data, mask, value):
out = rmm.device_array_like(data)
out.copy_to_device(data)
configured = gpu_fill_masked.forall(data.size)
configured(value, mask, out)
if out.size > 0:
out.copy_to_device(data)
configured = gpu_fill_masked.forall(data.size)
configured(value, mask, out)
return out


Expand Down