# Buggy code
def _install():
    from ..core import DATAFRAME_TYPE, SERIES_TYPE, INDEX_TYPE
    from .string_ import _string_method_to_handlers
    from .datetimes import _datetime_method_to_handlers
    from .accessor import StringAccessor, DatetimeAccessor, CachedAccessor

    for t in DATAFRAME_TYPE:
        setattr(t, "to_gpu", to_gpu)
        setattr(t, "to_cpu", to_cpu)
        setattr(t, "rechunk", rechunk)
        setattr(t, "describe", describe)
        setattr(t, "apply", df_apply)
        setattr(t, "transform", df_transform)
        setattr(t, "fillna", fillna)
        setattr(t, "ffill", ffill)
        setattr(t, "bfill", bfill)
        setattr(t, "isna", isna)
        setattr(t, "isnull", isnull)
        setattr(t, "notna", notna)
        setattr(t, "notnull", notnull)
        setattr(t, "dropna", df_dropna)
        setattr(t, "shift", shift)
        setattr(t, "tshift", tshift)
        setattr(t, "diff", df_diff)
        setattr(t, "astype", astype)
        setattr(t, "drop", df_drop)
        setattr(t, "pop", df_pop)
        setattr(
            t, "__delitem__", lambda df, items: df_drop(df, items, axis=1, inplace=True)
        )
        setattr(t, "drop_duplicates", df_drop_duplicates)
        setattr(t, "melt", melt)

    for t in SERIES_TYPE:
        setattr(t, "to_gpu", to_gpu)
        setattr(t, "to_cpu", to_cpu)
        setattr(t, "rechunk", rechunk)
        setattr(t, "map", map_)
        setattr(t, "describe", describe)
        setattr(t, "apply", series_apply)
        setattr(t, "transform", series_transform)
        setattr(t, "fillna", fillna)
        setattr(t, "ffill", ffill)
        setattr(t, "bfill", bfill)
        setattr(t, "isin", isin)
        setattr(t, "isna", isna)
        setattr(t, "isnull", isnull)
        setattr(t, "notna", notna)
        setattr(t, "notnull", notnull)
        setattr(t, "dropna", series_dropna)
        setattr(t, "shift", shift)
        setattr(t, "tshift", tshift)
        setattr(t, "diff", series_diff)
        setattr(t, "value_counts", value_counts)
        setattr(t, "astype", astype)
        setattr(t, "drop", series_drop)
        setattr(t, "drop_duplicates", series_drop_duplicates)

    for t in INDEX_TYPE:
        setattr(t, "rechunk", rechunk)
        setattr(t, "drop", index_drop)
        setattr(t, "drop_duplicates", index_drop_duplicates)

    for method in _string_method_to_handlers:
        if not hasattr(StringAccessor, method):
            StringAccessor._register(method)

    for method in _datetime_method_to_handlers:
        if not hasattr(DatetimeAccessor, method):
            DatetimeAccessor._register(method)

    for series in SERIES_TYPE:
        series.str = CachedAccessor("str", StringAccessor)
        series.dt = CachedAccessor("dt", DatetimeAccessor)


# Traceback (AttributeError)
In [25]: merge_df = parsing_df.append(pFold_4_df)

In [26]: mDf_g = merge_df.groupby(["query","template"])

In [27]: mDf_g.execute()
Out[27]: ---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/anaconda3/envs/py37/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj)
700                 type_pprinters=self.type_printers,
701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
703             printer.flush()
704             return stream.getvalue()

~/anaconda3/envs/py37/lib/python3.7/site-packages/IPython/lib/pretty.py in pretty(self, obj)
392                         if cls is not object \
393                                 and callable(cls.__dict__.get('__repr__')):
--> 394                             return _repr_pprint(obj, self, cycle)
395
396             return _default_pprint(obj, self, cycle)

~/anaconda3/envs/py37/lib/python3.7/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
698     """A pprint that just redirects to the normal repr function."""
699     # Find newlines and replace them with p.break_()
--> 700     output = repr(obj)
701     lines = output.splitlines()
702     with p.group():

~/anaconda3/envs/py37/lib/python3.7/site-packages/mars/dataframe/core.py in __repr__(self)
998
999     def __repr__(self):
-> 1000         return self._to_str(representation=True)
1001
1002     def _repr_html_(self):

~/anaconda3/envs/py37/lib/python3.7/site-packages/mars/dataframe/core.py in _to_str(self, representation)
968         else:
969             corner_data = fetch_corner_data(
--> 970                 self, session=self._executed_sessions[-1])
971
972             buf = StringIO()

~/anaconda3/envs/py37/lib/python3.7/site-packages/mars/dataframe/utils.py in fetch_corner_data(df_or_series, session)
768         return df_or_series.fetch(session=session)
769     else:
--> 770         head = iloc(df_or_series)[:index_size]
771         tail = iloc(df_or_series)[-index_size:]
772         head_data, tail_data = \

~/anaconda3/envs/py37/lib/python3.7/site-packages/mars/dataframe/indexing/iloc.py in __getitem__(self, indexes)
111         else:
112             op = SeriesIlocGetItem(indexes=process_iloc_indexes(self._obj, indexes))
--> 113         return op(self._obj)
114
115     def __setitem__(self, indexes, value):

~/anaconda3/envs/py37/lib/python3.7/site-packages/mars/dataframe/indexing/iloc.py in __call__(self, series)
485             index_value = indexing_index_value(series.index_value, self.indexes[0])
486             inputs = [series] + [index for index in self._indexes if isinstance(index, (Base, Entity))]
--> 487             return self.new_series(inputs, shape=shape, dtype=series.dtype,
488                                    index_value=index_value, name=series.name)
489

AttributeError: 'DataFrameGroupByData' object has no attribute 'dtype'

# Fixed code
def _install():
    from ..core import DATAFRAME_TYPE, SERIES_TYPE, INDEX_TYPE
    from .standardize_range_index import ChunkStandardizeRangeIndex
    from .string_ import _string_method_to_handlers
    from .datetimes import _datetime_method_to_handlers
    from .accessor import StringAccessor, DatetimeAccessor, CachedAccessor

    for t in DATAFRAME_TYPE:
        setattr(t, "to_gpu", to_gpu)
        setattr(t, "to_cpu", to_cpu)
        setattr(t, "rechunk", rechunk)
        setattr(t, "describe", describe)
        setattr(t, "apply", df_apply)
        setattr(t, "transform", df_transform)
        setattr(t, "fillna", fillna)
        setattr(t, "ffill", ffill)
        setattr(t, "bfill", bfill)
        setattr(t, "isna", isna)
        setattr(t, "isnull", isnull)
        setattr(t, "notna", notna)
        setattr(t, "notnull", notnull)
        setattr(t, "dropna", df_dropna)
        setattr(t, "shift", shift)
        setattr(t, "tshift", tshift)
        setattr(t, "diff", df_diff)
        setattr(t, "astype", astype)
        setattr(t, "drop", df_drop)
        setattr(t, "pop", df_pop)
        setattr(
            t, "__delitem__", lambda df, items: df_drop(df, items, axis=1, inplace=True)
        )
        setattr(t, "drop_duplicates", df_drop_duplicates)
        setattr(t, "melt", melt)

    for t in SERIES_TYPE:
        setattr(t, "to_gpu", to_gpu)
        setattr(t, "to_cpu", to_cpu)
        setattr(t, "rechunk", rechunk)
        setattr(t, "map", map_)
        setattr(t, "describe", describe)
        setattr(t, "apply", series_apply)
        setattr(t, "transform", series_transform)
        setattr(t, "fillna", fillna)
        setattr(t, "ffill", ffill)
        setattr(t, "bfill", bfill)
        setattr(t, "isin", isin)
        setattr(t, "isna", isna)
        setattr(t, "isnull", isnull)
        setattr(t, "notna", notna)
        setattr(t, "notnull", notnull)
        setattr(t, "dropna", series_dropna)
        setattr(t, "shift", shift)
        setattr(t, "tshift", tshift)
        setattr(t, "diff", series_diff)
        setattr(t, "value_counts", value_counts)
        setattr(t, "astype", astype)
        setattr(t, "drop", series_drop)
        setattr(t, "drop_duplicates", series_drop_duplicates)

    for t in INDEX_TYPE:
        setattr(t, "rechunk", rechunk)
        setattr(t, "drop", index_drop)
        setattr(t, "drop_duplicates", index_drop_duplicates)

    for method in _string_method_to_handlers:
        if not hasattr(StringAccessor, method):
            StringAccessor._register(method)

    for method in _datetime_method_to_handlers:
        if not hasattr(DatetimeAccessor, method):
            DatetimeAccessor._register(method)

    for series in SERIES_TYPE:
        series.str = CachedAccessor("str", StringAccessor)
        series.dt = CachedAccessor("dt", DatetimeAccessor)