# Buggy code
def _as_table(self, i1, i2, j1=None, j2=None, format="html"):
    from .formatting import _format_value

    parts = []  # """<div>%s (length=%d)</div>""" % (self.name, len(self))]
    parts += ["<table class='table-striped'>"]

    aliases_reverse = {value: key for key, value in self._column_aliases.items()}
    column_names = self.get_column_names()
    values_list = []
    values_list.append(["#", []])
    # parts += ["<thead><tr>"]
    for name in column_names:
        values_list.append([aliases_reverse.get(name, name), []])
        # parts += ["<th>%s</th>" % name]
    # parts += ["</tr></thead>"]

    def table_part(k1, k2, parts):
        N = k2 - k1
        # slicing will invoke .extract which will make the evaluation
        # much quicker
        df = self[k1:k2]
        try:
            values = dict(zip(column_names, df.evaluate(column_names)))
        except:
            values = {}
            for i, name in enumerate(column_names):
                try:
                    values[name] = df.evaluate(name)
                except:
                    values[name] = ["error"] * (N)
                    logger.exception(
                        "error evaluating: %s at rows %i-%i" % (name, k1, k2)
                    )
        for i in range(k2 - k1):
            # parts += ["<tr>"]
            # parts += ["<td><i style='opacity: 0.6'>{:,}</i></td>".format(i + k1)]
            if format == "html":
                value = "<i style='opacity: 0.6'>{:,}</i>".format(i + k1)
            else:
                value = "{:,}".format(i + k1)
            values_list[0][1].append(value)
            for j, name in enumerate(column_names):
                value = values[name][i]
                value = _format_value(value)
                values_list[j + 1][1].append(value)
            # parts += ["</tr>"]
        # return values_list

    if i2 - i1 > 0:
        parts = table_part(i1, i2, parts)
        if j1 is not None and j2 is not None:
            values_list[0][1].append("...")
            for i in range(len(column_names)):
                # parts += ["<td>...</td>"]
                values_list[i + 1][1].append("...")

            # parts = table_part(j1, j2, parts)
            table_part(j1, j2, parts)
    else:
        for header, values in values_list:
            values.append(None)
    # parts += "</table>"
    # html = "".join(parts)
    # return html
    values_list = dict(values_list)
    # print(values_list)
    import tabulate

    table_text = tabulate.tabulate(values_list, headers="keys", tablefmt=format)
    if i2 - i1 == 0:
        if self._length_unfiltered != len(self):
            footer_text = "No rows to display (because of filtering)."
        else:
            footer_text = "No rows to display."
        if format == "html":
            table_text += f"<i>{footer_text}</i>"
        if format == "plain":
            table_text += f"\n{footer_text}"
    return table_text


# Traceback (AttributeError)
could not convert column 0, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 0, error: TypeError('getattr(): attribute name must be string',)
could not convert column 1, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 1, error: TypeError('getattr(): attribute name must be string',)
could not convert column 2, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 2, error: TypeError('getattr(): attribute name must be string',)
could not convert column 3, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 3, error: TypeError('getattr(): attribute name must be string',)
could not convert column 4, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 4, error: TypeError('getattr(): attribute name must be string',)
could not convert column 5, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 5, error: TypeError('getattr(): attribute name must be string',)
could not convert column 6, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 6, error: TypeError('getattr(): attribute name must be string',)
could not convert column 7, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 7, error: TypeError('getattr(): attribute name must be string',)
could not convert column 8, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 8, error: TypeError('getattr(): attribute name must be string',)
could not convert column 9, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 9, error: TypeError('getattr(): attribute name must be string',)
could not convert column 10, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 10, error: TypeError('getattr(): attribute name must be string',)
could not convert column 11, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 11, error: TypeError('getattr(): attribute name must be string',)
could not convert column 12, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 12, error: TypeError('getattr(): attribute name must be string',)
could not convert column 13, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 13, error: TypeError('getattr(): attribute name must be string',)
could not convert column 14, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 14, error: TypeError('getattr(): attribute name must be string',)
could not convert column 15, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 15, error: TypeError('getattr(): attribute name must be string',)
could not convert column 16, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 16, error: TypeError('getattr(): attribute name must be string',)
could not convert column 17, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 17, error: TypeError('getattr(): attribute name must be string',)
could not convert column 18, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 18, error: TypeError('getattr(): attribute name must be string',)
could not convert column 19, error: TypeError('getattr(): attribute name must be string',), will try to convert it to string
Giving up column 19, error: TypeError('getattr(): attribute name must be string',)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/IPython/core/formatters.py in __call__(self, obj, include, exclude)
968                 d['include'] = include
969                 d['exclude'] = exclude
--> 970                 return method(**d)
971             return None
972         else:

5 frames
/usr/local/lib/python3.6/dist-packages/vaex/dataframe.py in column_filter(name)
3486             if not strings and (self.dtype(name) == str_type or self.dtype(name).type == np.string_):
3487                 return False
-> 3488             if not hidden and name.startswith('__'):
3489                 return False
3490             return True

AttributeError: 'int' object has no attribute 'startswith'
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-a7b44e392414> in <module>()
3 df = pd.DataFrame(X)
4 df['target'] = y
----> 5 vaex.from_pandas(df)

2 frames
/usr/local/lib/python3.6/dist-packages/IPython/core/formatters.py in format(self, obj, include, exclude)
150             return {}, {}
151
--> 152         format_dict, md_dict = self.mimebundle_formatter(obj, include=include, exclude=exclude)
153
154         if format_dict or md_dict:

TypeError: 'NoneType' object is not iterable

# Fixed code
def _as_table(self, i1, i2, j1=None, j2=None, format="html"):
    from .formatting import _format_value

    parts = []  # """<div>%s (length=%d)</div>""" % (self.name, len(self))]
    parts += ["<table class='table-striped'>"]

    aliases_reverse = {value: key for key, value in self._column_aliases.items()}
    # we need to get the underlying names since we use df.evaluate
    column_names = self.get_column_names(alias=False)
    values_list = []
    values_list.append(["#", []])
    # parts += ["<thead><tr>"]
    for name in column_names:
        values_list.append([aliases_reverse.get(name, name), []])
        # parts += ["<th>%s</th>" % name]
    # parts += ["</tr></thead>"]

    def table_part(k1, k2, parts):
        N = k2 - k1
        # slicing will invoke .extract which will make the evaluation
        # much quicker
        df = self[k1:k2]
        try:
            values = dict(zip(column_names, df.evaluate(column_names)))
        except:
            values = {}
            for i, name in enumerate(column_names):
                try:
                    values[name] = df.evaluate(name)
                except:
                    values[name] = ["error"] * (N)
                    logger.exception(
                        "error evaluating: %s at rows %i-%i" % (name, k1, k2)
                    )
        for i in range(k2 - k1):
            # parts += ["<tr>"]
            # parts += ["<td><i style='opacity: 0.6'>{:,}</i></td>".format(i + k1)]
            if format == "html":
                value = "<i style='opacity: 0.6'>{:,}</i>".format(i + k1)
            else:
                value = "{:,}".format(i + k1)
            values_list[0][1].append(value)
            for j, name in enumerate(column_names):
                value = values[name][i]
                value = _format_value(value)
                values_list[j + 1][1].append(value)
            # parts += ["</tr>"]
        # return values_list

    if i2 - i1 > 0:
        parts = table_part(i1, i2, parts)
        if j1 is not None and j2 is not None:
            values_list[0][1].append("...")
            for i in range(len(column_names)):
                # parts += ["<td>...</td>"]
                values_list[i + 1][1].append("...")

            # parts = table_part(j1, j2, parts)
            table_part(j1, j2, parts)
    else:
        for header, values in values_list:
            values.append(None)
    # parts += "</table>"
    # html = "".join(parts)
    # return html
    values_list = dict(values_list)
    # print(values_list)
    import tabulate

    table_text = tabulate.tabulate(values_list, headers="keys", tablefmt=format)
    if i2 - i1 == 0:
        if self._length_unfiltered != len(self):
            footer_text = "No rows to display (because of filtering)."
        else:
            footer_text = "No rows to display."
        if format == "html":
            table_text += f"<i>{footer_text}</i>"
        if format == "plain":
            table_text += f"\n{footer_text}"
    return table_text