# Buggy code
def groupby(
    self,
    by=None,
    axis=0,
    level=None,
    as_index=True,
    sort=True,
    group_keys=True,
    squeeze=False,
    observed=False,
    **kwargs,
):
    """Apply a groupby to this DataFrame. See _groupby() remote task.
    Args:
        by: The value to groupby.
        axis: The axis to groupby.
        level: The level of the groupby.
        as_index: Whether or not to store result as index.
        sort: Whether or not to sort the result by the index.
        group_keys: Whether or not to group the keys.
        squeeze: Whether or not to squeeze.
    Returns:
        A new DataFrame resulting from the groupby.
    """
    axis = self._get_axis_number(axis)
    idx_name = None
    if callable(by):
        by = self.index.map(by)
    elif isinstance(by, str):
        idx_name = by
        by = self.__getitem__(by)._query_compiler
    elif is_list_like(by):
        if isinstance(by, Series):
            idx_name = by.name
            by = by.values
        mismatch = len(by) != len(self) if axis == 0 else len(by) != len(self.columns)
        if mismatch and all(obj in self for obj in by):
            # In the future, we will need to add logic to handle this, but for now
            # we default to pandas in this case.
            pass
        elif mismatch:
            raise KeyError(next(x for x in by if x not in self))

    from .groupby import DataFrameGroupBy

    return DataFrameGroupBy(
        self,
        by,
        axis,
        level,
        as_index,
        sort,
        group_keys,
        squeeze,
        idx_name,
        observed=observed,
        **kwargs,
    )


# Traceback (KeyError)
p0 Index(['data0', 'data1', 'data2'], dtype='object')
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-6-704c3a79c97b> in <module>()
----> 1 df_g=csv2.groupby('p0').get_group('A')

~/.local/lib/python3.7/site-packages/modin/pandas/dataframe.py in groupby(self, by, axis, level, as_index, sort, group_keys, squeeze, observed, **kwargs)
353         elif isinstance(by, string_types):
354             idx_name = by
--> 355             by = self.__getitem__(by)._query_compiler
356         elif is_list_like(by):
357             if isinstance(by, Series):

~/.local/lib/python3.7/site-packages/modin/pandas/base.py in __getitem__(self, key)
3220             return self._getitem_slice(indexer)
3221         else:
-> 3222             return self._getitem(key)
3223
3224     def _getitem_slice(self, key):

~/.local/lib/python3.7/site-packages/modin/pandas/dataframe.py in _getitem(self, key)
1835         else:
1836             print(key, self.columns)
-> 1837             return self._getitem_column(key)
1838
1839     def _getitem_column(self, key):

~/.local/lib/python3.7/site-packages/modin/pandas/dataframe.py in _getitem_column(self, key)
1839     def _getitem_column(self, key):
1840         if key not in self.keys():
-> 1841             raise KeyError("{}".format(key))
1842         s = self._reduce_dimension(self._query_compiler.getitem_column_array([key]))
1843         s._parent = self

KeyError: 'p0'

# Fixed code
def groupby(
    self,
    by=None,
    axis=0,
    level=None,
    as_index=True,
    sort=True,
    group_keys=True,
    squeeze=False,
    observed=False,
    **kwargs,
):
    """Apply a groupby to this DataFrame. See _groupby() remote task.
    Args:
        by: The value to groupby.
        axis: The axis to groupby.
        level: The level of the groupby.
        as_index: Whether or not to store result as index.
        sort: Whether or not to sort the result by the index.
        group_keys: Whether or not to group the keys.
        squeeze: Whether or not to squeeze.
    Returns:
        A new DataFrame resulting from the groupby.
    """
    axis = self._get_axis_number(axis)
    idx_name = None
    if callable(by):
        by = self.index.map(by)
    elif isinstance(by, str):
        idx_name = by
        if (
            isinstance(self.axes[axis], pandas.MultiIndex)
            and by in self.axes[axis].names
        ):
            # In this case we pass the string value of the name through to the
            # partitions. This is more efficient than broadcasting the values.
            pass
        else:
            by = self.__getitem__(by)._query_compiler
    elif is_list_like(by):
        if isinstance(by, Series):
            idx_name = by.name
            by = by.values
        mismatch = len(by) != len(self) if axis == 0 else len(by) != len(self.columns)
        if mismatch and all(obj in self for obj in by):
            # In the future, we will need to add logic to handle this, but for now
            # we default to pandas in this case.
            pass
        elif mismatch:
            raise KeyError(next(x for x in by if x not in self))

    if by is None and level is not None and axis == 0:
        if not isinstance(level, str):
            by = self.axes[axis].names[level]
            level = None
        else:
            by = level
            level = None
    from .groupby import DataFrameGroupBy

    return DataFrameGroupBy(
        self,
        by,
        axis,
        level,
        as_index,
        sort,
        group_keys,
        squeeze,
        idx_name,
        observed=observed,
        **kwargs,
    )