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

Function get_groupby

pandas/core/groupby/groupby.py:6167–6257  ·  view source on GitHub ↗

Class for grouping and aggregating relational data. See aggregate, transform, and apply functions on this object. It's easiest to use obj.groupby(...) to use GroupBy, but you can also do: :: grouped = groupby(obj, ...) Parameters ---------- obj : pandas obje

(
    obj: NDFrame,
    by: _KeysArgType | None = None,
    grouper: ops.BaseGrouper | None = None,
    group_keys: bool = True,
)

Source from the content-addressed store, hash-verified

6165
6166
6167def get_groupby(
6168 obj: NDFrame,
6169 by: _KeysArgType | None = None,
6170 grouper: ops.BaseGrouper | None = None,
6171 group_keys: bool = True,
6172) -> GroupBy:
6173 """
6174 Class for grouping and aggregating relational data.
6175
6176 See aggregate, transform, and apply functions on this object.
6177
6178 It's easiest to use obj.groupby(...) to use GroupBy, but you can also do:
6179
6180 ::
6181
6182 grouped = groupby(obj, ...)
6183
6184 Parameters
6185 ----------
6186 obj : pandas object
6187 level : int, default None
6188 Level of MultiIndex
6189 groupings : list of Grouping objects
6190 Most users should ignore this
6191 exclusions : array-like, optional
6192 List of columns to exclude
6193 name : str
6194 Most users should ignore this
6195
6196 Returns
6197 -------
6198 **Attributes**
6199 groups : dict
6200 {group name -> group labels}
6201 len(grouped) : int
6202 Number of groups
6203
6204 Notes
6205 -----
6206 After grouping, see aggregate, apply, and transform functions. Here are
6207 some other brief notes about usage. When grouping by multiple groups, the
6208 result index will be a MultiIndex (hierarchical) by default.
6209
6210 Iteration produces (key, group) tuples, i.e. chunking the data by group. So
6211 you can write code like:
6212
6213 ::
6214
6215 grouped = obj.groupby(keys)
6216 for key, group in grouped:
6217 # do something with the data
6218
6219 Function calls on GroupBy, if not specially implemented, "dispatch" to the
6220 grouped data. So if you group a DataFrame and wish to invoke the std()
6221 method on each group, you can simply do:
6222
6223 ::
6224

Callers 4

_gotitemMethod · 0.90
test_getitemMethod · 0.90
test_getitem_multipleMethod · 0.90

Calls 2

SeriesGroupByClass · 0.90
DataFrameGroupByClass · 0.90

Tested by 2

test_getitemMethod · 0.72
test_getitem_multipleMethod · 0.72