# Buggy code
def __init__(
    self,
    obj,
    orient,
    date_format,
    double_precision,
    ensure_ascii,
    date_unit,
    default_handler=None,
):
    """
    Adds a `schema` attribut with the Table Schema, resets
    the index (can't do in caller, because the schema inference needs
    to know what the index is, forces orient to records, and forces
    date_format to 'iso'.
    """
    super(JSONTableWriter, self).__init__(
        obj,
        orient,
        date_format,
        double_precision,
        ensure_ascii,
        date_unit,
        default_handler=default_handler,
    )

    if date_format != "iso":
        msg = (
            "Trying to write with `orient='table'` and "
            "`date_format='%s'`. Table Schema requires dates "
            "to be formatted with `date_format='iso'`" % date_format
        )
        raise ValueError(msg)

    self.schema = build_table_schema(obj)

    # TODO: Do this timedelta properly in objToJSON.c See GH #15137
    if (
        (obj.ndim == 1)
        and (obj.name in set(obj.index.names))
        or len(obj.columns & obj.index.names)
    ):
        msg = "Overlapping names between the index and columns"
        raise ValueError(msg)

    obj = obj.copy()
    timedeltas = obj.select_dtypes(include=["timedelta"]).columns
    if len(timedeltas):
        obj[timedeltas] = obj[timedeltas].applymap(lambda x: x.isoformat())
    # Convert PeriodIndex to datetimes before serialzing
    if is_period_dtype(obj.index):
        obj.index = obj.index.to_timestamp()

    self.obj = obj.reset_index()
    self.date_format = "iso"
    self.orient = "records"


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/Users/kylek/code/src/github.com/pandas-dev/pandas/pandas/indexes/multi.py in _convert_can_do_setop(self, other)
2513                 try:
-> 2514                     other = MultiIndex.from_tuples(other)
2515                 except:

/Users/kylek/code/src/github.com/pandas-dev/pandas/pandas/indexes/multi.py in from_tuples(cls, tuples, sortorder, names)
1128         elif isinstance(tuples, list):
-> 1129             arrays = list(lib.to_object_array_tuples(tuples).T)
1130         else:

TypeError: Argument 'rows' has incorrect type (expected list, got FrozenList)

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/usr/local/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
880             method = get_real_method(obj, self.print_method)
881             if method is not None:
--> 882                 method()
883                 return True
884

/Users/kylek/code/src/github.com/pandas-dev/pandas/pandas/core/generic.py in _ipython_display_(self)
138         latex = self._repr_latex_() if hasattr(self, '_repr_latex_') else None
139         html = self._repr_html_() if hasattr(self, '_repr_html_') else None
--> 140         table_schema = self._repr_table_schema_()
141         # We need the inital newline since we aren't going through the
142         # usual __repr__. See

/Users/kylek/code/src/github.com/pandas-dev/pandas/pandas/core/generic.py in _repr_table_schema_(self)
156         if config.get_option("display.html.table_schema"):
157             data = self.head(config.get_option('display.max_rows'))
--> 158             payload = json.loads(data.to_json(orient='table'),
159                                  object_pairs_hook=collections.OrderedDict)
160             return payload

/Users/kylek/code/src/github.com/pandas-dev/pandas/pandas/core/generic.py in to_json(self, path_or_buf, orient, date_format, double_precision, force_ascii, date_unit, default_handler, lines)
1232                             force_ascii=force_ascii, date_unit=date_unit,
1233                             default_handler=default_handler,
-> 1234                             lines=lines)
1235
1236     def to_hdf(self, path_or_buf, key, **kwargs):

/Users/kylek/code/src/github.com/pandas-dev/pandas/pandas/io/json/json.py in to_json(path_or_buf, obj, orient, date_format, double_precision, force_ascii, date_unit, default_handler, lines)
44         obj, orient=orient, date_format=date_format,
45         double_precision=double_precision, ensure_ascii=force_ascii,
---> 46         date_unit=date_unit, default_handler=default_handler).write()
47
48     if lines:

/Users/kylek/code/src/github.com/pandas-dev/pandas/pandas/io/json/json.py in __init__(self, obj, orient, date_format, double_precision, ensure_ascii, date_unit, default_handler)
141         # TODO: Do this timedelta properly in objToJSON.c See GH #15137
142         if ((obj.ndim == 1) and (obj.name in set(obj.index.names)) or
--> 143                 len(obj.columns &amp; obj.index.names)):
144             msg = "Overlapping names between the index and columns"
145             raise ValueError(msg)

/Users/kylek/code/src/github.com/pandas-dev/pandas/pandas/indexes/base.py in __and__(self, other)
2046
2047     def __and__(self, other):
-> 2048         return self.intersection(other)
2049
2050     def __or__(self, other):

/Users/kylek/code/src/github.com/pandas-dev/pandas/pandas/indexes/multi.py in intersection(self, other)
2447         """
2448         self._assert_can_do_setop(other)
-> 2449         other, result_names = self._convert_can_do_setop(other)
2450
2451         if self.equals(other):

/Users/kylek/code/src/github.com/pandas-dev/pandas/pandas/indexes/multi.py in _convert_can_do_setop(self, other)
2514                     other = MultiIndex.from_tuples(other)
2515                 except:
-> 2516                     raise TypeError(msg)
2517         else:
2518             result_names = self.names if self.names == other.names else None

TypeError: other must be a MultiIndex or a list of tuples

# Fixed code
def __init__(
    self,
    obj,
    orient,
    date_format,
    double_precision,
    ensure_ascii,
    date_unit,
    default_handler=None,
):
    """
    Adds a `schema` attribut with the Table Schema, resets
    the index (can't do in caller, because the schema inference needs
    to know what the index is, forces orient to records, and forces
    date_format to 'iso'.
    """
    super(JSONTableWriter, self).__init__(
        obj,
        orient,
        date_format,
        double_precision,
        ensure_ascii,
        date_unit,
        default_handler=default_handler,
    )

    if date_format != "iso":
        msg = (
            "Trying to write with `orient='table'` and "
            "`date_format='%s'`. Table Schema requires dates "
            "to be formatted with `date_format='iso'`" % date_format
        )
        raise ValueError(msg)

    self.schema = build_table_schema(obj)

    # NotImplementd on a column MultiIndex
    if obj.ndim == 2 and isinstance(obj.columns, MultiIndex):
        raise NotImplementedError("orient='table' is not supported for MultiIndex")

    # TODO: Do this timedelta properly in objToJSON.c See GH #15137
    if (
        (obj.ndim == 1)
        and (obj.name in set(obj.index.names))
        or len(obj.columns & obj.index.names)
    ):
        msg = "Overlapping names between the index and columns"
        raise ValueError(msg)

    obj = obj.copy()
    timedeltas = obj.select_dtypes(include=["timedelta"]).columns
    if len(timedeltas):
        obj[timedeltas] = obj[timedeltas].applymap(lambda x: x.isoformat())
    # Convert PeriodIndex to datetimes before serialzing
    if is_period_dtype(obj.index):
        obj.index = obj.index.to_timestamp()

    self.obj = obj.reset_index()
    self.date_format = "iso"
    self.orient = "records"