The doc string of GroupByMoments is not aligned with the functionality of the operator:
import cudf as gd
import pandas as pd
import nvtabular as nvt
from nvtabular.ops import Normalize, FillMissing, Categorify, Moments, Median, Encoder, LogOp, ZeroFill, GroupByMoments
from nvtabular.ops import *
cat_1 = np.asarray(['a']*12 + ['b']*10 + ['c']*10)
num_1 = np.asarray([1,1,2,2,2,1,1,5,4,4,4,4, 1,2,3,4,5,6,7,8,9,10, 1,2,3,4,5,6,7,8,9,10])
pdf_1 = pd.DataFrame({'cat': cat_1, 'num': num_1})
gdf = cudf.from_pandas(pdf_1)
proc = nvt.Workflow(cat_names=['cat'], cont_names=['num'], label_name=[])
proc.finalize()
# First bug
gm = GroupByMoments(
cat_names='cat',
stats=['count']
)
gm.apply_op(gdf, columns_ctx=proc.columns_ctx, input_cols='all', target_cols=['base'])
gm.read_fin()
#TypeError: only integer scalar arrays can be converted to a scalar index
# Second bug
gm = GroupByMoments(
cat_names='cat',
cont_names='num',
stats=['count']
)
gm.apply_op(gdf, columns_ctx=proc.columns_ctx, input_cols='all', target_cols=['base'])
gm.read_fin()
#AttributeError: 'str' object has no attribute 'copy'
# This works
gm = GroupByMoments(
cat_names='cat',
cont_names=['num'],
stats=['count']
)
gm.apply_op(gdf, columns_ctx=proc.columns_ctx, input_cols='all', target_cols=['base'])
gm.read_fin()