def _group_longform(self, vals, grouper, order):
        # Ensure that the groupby will work
        if not isinstance(vals, pd.Series):
            vals = pd.Series(vals)

        # Group the val data
        grouped_vals = vals.groupby(grouper)
        out_data = []
        for g in order:
            try:
                g_vals = np.asarray(grouped_vals.get_group(g))
            except KeyError:
                g_vals = np.array([])
            out_data.append(g_vals)

        # Get the vals axis label
        label = vals.name

        return out_data, label
Group a long-form variable by another with correct order.
dataset/ETHPy150Open mwaskom/seaborn/seaborn/categorical.py/_CategoricalPlotter._group_longform