def METHOD_NAME(cls, ctx, op: "GroupByHead"):
    in_data = ctx[op.inputs[0].key]
    params = op.groupby_params.copy()
    selection = params.pop("selection", None)
    if hasattr(in_data, "groupby"):
        grouped = in_data.groupby(**params)
    else:
        grouped = in_data
    if selection:
        grouped = grouped[selection]
    result = grouped.head(op.row_count)
    if not op.enable_negative and op.row_count < 0:
        result = result.iloc[:0]
    ctx[op.outputs[0].key] = result