Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _row_number_grouped(g: GroupBy) -> GroupBy:
out = np.ones(len(g.obj), dtype = int)
indices = g.grouper.indices
for g_key, inds in indices.items():
out[inds] = np.arange(1, len(inds) + 1, dtype = int)
return _regroup(out, g)
def _lag_grouped(x, n = 1, default = None):
res = x.shift(n, fill_value = default)
return _regroup(res, x)
def f(x, y):
_validate_data_args(x, y = y)
left, right, groupby = _maybe_broadcast(x, y)
op_function = getattr(left, name)
res = op_function(right)
return _regroup(res, groupby)
def _lead_grouped(x, n = 1, default = None):
res = x.shift(-1*n, fill_value = default)
return _regroup(res, x)
def f(__ser, *args, **kwargs):
_validate_data_args(__ser)
res = _apply_grouped_method(__ser, name, is_property, accessor, args, kwargs)
return _regroup(res, __ser)
def f(__ser, *args, **kwargs):
_validate_data_args(__ser)
res = _apply_grouped_method(__ser.obj, name, is_property, accessor, args, kwargs)
return _regroup(res, __ser)