# Buggy code
def __repr__(self):
    from pandas.io.formats import console

    num_rows = pandas.get_option("display.max_rows") or 10
    num_cols = pandas.get_option("display.max_columns") or 20
    if pandas.get_option("display.max_columns") is None and pandas.get_option(
        "display.expand_frame_repr"
    ):
        width, _ = console.get_console_size()
        col_counter = 0
        i = 0
        while col_counter < width:
            col_counter += len(str(self.columns[i])) + 1
            i += 1

        num_cols = i
        i = len(self.columns) - 1
        col_counter = 0
        while col_counter < width:
            col_counter += len(str(self.columns[i])) + 1
            i -= 1

        num_cols += len(self.columns) - i
    result = repr(self._build_repr_df(num_rows, num_cols))
    if len(self.index) > num_rows or len(self.columns) > num_cols:
        # The split here is so that we don't repr pandas row lengths.
        return result.rsplit("\n\n", 1)[0] + "\n\n[{0} rows x {1} columns]".format(
            len(self.index), len(self.columns)
        )
    else:
        return result


# Traceback (IndexError)
Python 3.8.3 (default, Jun  9 2020, 17:49:41)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import modin.pandas as pandas
pandas.DataFrame()
UserWarning: Distributing <class 'NoneType'> object. This may take some time.
Empty DataFrame
Columns: []
Index: []
pandas.set_option("display.max_rows", None)
pandas.DataFrame()
UserWarning: Distributing <class 'NoneType'> object. This may take some time.
Empty DataFrame
Columns: []
Index: []
pandas.set_option("display.max_columns", None)
pandas.DataFrame()
UserWarning: Distributing <class 'NoneType'> object. This may take some time.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/.cache/pypoetry/virtualenvs/onepassword-etl-NcjVOHQt-py3.8/src/modin/modin/pandas/dataframe.py", line 151, in __repr__
col_counter += len(str(self.columns[i])) + 1
File "/root/.cache/pypoetry/virtualenvs/onepassword-etl-NcjVOHQt-py3.8/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3930, in __getitem__
return getitem(key)
IndexError: index 0 is out of bounds for axis 0 with size 0
```

# Fixed code
def __repr__(self):
    from pandas.io.formats import console

    num_rows = pandas.get_option("display.max_rows") or 10
    num_cols = pandas.get_option("display.max_columns") or 20
    if pandas.get_option("display.max_columns") is None and pandas.get_option(
        "display.expand_frame_repr"
    ):
        width, _ = console.get_console_size()
        width = min(width, len(self.columns))
        col_counter = 0
        i = 0
        while col_counter < width:
            col_counter += len(str(self.columns[i])) + 1
            i += 1

        num_cols = i
        i = len(self.columns) - 1
        col_counter = 0
        while col_counter < width:
            col_counter += len(str(self.columns[i])) + 1
            i -= 1

        num_cols += len(self.columns) - i
    result = repr(self._build_repr_df(num_rows, num_cols))
    if len(self.index) > num_rows or len(self.columns) > num_cols:
        # The split here is so that we don't repr pandas row lengths.
        return result.rsplit("\n\n", 1)[0] + "\n\n[{0} rows x {1} columns]".format(
            len(self.index), len(self.columns)
        )
    else:
        return result