def groupby(df, **specs):

    spec_cols = collect_attribute_columns(**specs)

    # if there was any input for chart attributes, which require grouping
    if spec_cols:
        # df = df.sort(columns=spec_cols)

        for name, data in df.groupby(spec_cols, sort=False):

            attrs = {}
            group_label = {}

            for spec_name, spec in iteritems(specs):
                if spec.columns is not None:
                    # get index of the unique column values grouped on for this spec
                    name_idx = tuple([spec_cols.index(col) for col in spec.columns])

                    if isinstance(name, tuple):
                        # this handles the case of utilizing one or more and overlapping
                        # column names for different attrs
                        # name (label) is a tuple of the column values
                        # we extract only the data associated with the columns that this attr spec was configured with
                        label = itemgetter(*name_idx)(name)
                        cols = itemgetter(*name_idx)(spec_cols)
                    else:
                        label = name
                        cols = spec_cols[0]

                    if not isinstance(label, tuple):
                        label = (label, )

                    if not isinstance(cols, list) and not isinstance(cols, tuple):
                        cols = [cols]

                    for col, value in zip(cols, label):
                        group_label[col] = value

                else:
                    label = None

                # get attribute value for this spec, given the unique column values associated with it
                attrs[spec_name] = spec[label]

            yield DataGroup(label=group_label, data=data, attr_specs=attrs)

    # collect up the defaults from the attribute specs
    else:
        attrs = {}
        for spec_name, spec in iteritems(specs):
            attrs[spec_name] = spec[None]

        yield DataGroup(label=None, data=df, attr_specs=attrs)
Calculate the limit of each element in the matrix.
dataset/ETHPy150Open bokeh/bokeh/bokeh/charts/data_source.py/groupby--crossover with--dataset/ETHPy150Open sympy/sympy/sympy/matrices/matrices.py/MatrixBase.limit