MCPcopy
hub / github.com/pandas-dev/pandas / _get_grouper

Method _get_grouper

pandas/core/groupby/grouper.py:290–319  ·  view source on GitHub ↗

Parameters ---------- obj : Series or DataFrame Object being grouped. validate : bool, default True If True, validate the grouper. observed : bool, default True Whether only observed groups should be in the result. Only

(
        self, obj: NDFrameT, validate: bool = True, observed: bool = True
    )

Source from the content-addressed store, hash-verified

288 self._indexer: npt.NDArray[np.intp] | None = None
289
290 def _get_grouper(
291 self, obj: NDFrameT, validate: bool = True, observed: bool = True
292 ) -> tuple[ops.BaseGrouper, NDFrameT]:
293 """
294 Parameters
295 ----------
296 obj : Series or DataFrame
297 Object being grouped.
298 validate : bool, default True
299 If True, validate the grouper.
300 observed : bool, default True
301 Whether only observed groups should be in the result. Only
302 has an impact when grouping on categorical data.
303
304 Returns
305 -------
306 A tuple of grouper, obj (possibly sorted)
307 """
308 obj, _, _ = self._set_grouper(obj)
309 grouper, _, obj = get_grouper(
310 obj,
311 [self.key],
312 level=self.level,
313 sort=self.sort,
314 validate=validate,
315 dropna=self.dropna,
316 observed=observed,
317 )
318
319 return grouper, obj
320
321 def _set_grouper(
322 self, obj: NDFrameT, sort: bool = False, *, gpr_index: Index | None = None

Callers 3

test_apply_iterationFunction · 0.95
__init__Method · 0.45
get_grouperFunction · 0.45

Calls 2

_set_grouperMethod · 0.95
get_grouperFunction · 0.85

Tested by 1

test_apply_iterationFunction · 0.76