# Buggy code
def __init__(self, intent, source=None, title="", score=0.0):
    self._intent = intent  # This is the user's original intent to Vis
    self._inferred_intent = intent  # This is the re-written, expanded version of user's original intent (include inferred vis info)
    self._source = source  # This is the original data that is attached to the Vis
    self._vis_data = None  # This is the data that represents the Vis (e.g., selected, aggregated, binned)
    self._code = None
    self._mark = ""
    self._min_max = {}
    self._postbin = None
    self.title = title
    self.score = score
    self.refresh_source(self._source)


# Traceback (KeyError)
C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\formatters.py:345: UserWarning:
Unexpected error in rendering Lux widget and recommendations. Falling back to Pandas display.
Please report the following issue on Github: https://github.com/lux-org/lux/issues

C:\ProgramData\Anaconda3\lib\site-packages\lux\core\frame.py:689: UserWarning:Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 2898, in get_loc
return self._engine.get_loc(casted_key)
File "pandas\_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 1032, in pandas._libs.hashtable.Int64HashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 1039, in pandas._libs.hashtable.Int64HashTable.get_item
KeyError: 0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\lux\core\frame.py", line 641, in _repr_html_
self.maintain_recs()
File "C:\ProgramData\Anaconda3\lib\site-packages\lux\core\frame.py", line 472, in maintain_recs
custom_action_collection = custom_actions(rec_df)
File "C:\ProgramData\Anaconda3\lib\site-packages\lux\action\custom.py", line 75, in custom_actions
recommendation = lux.actions.__getattr__(action_name).action(ldf)
File "C:\ProgramData\Anaconda3\lib\site-packages\lux\action\enhance.py", line 67, in enhance
vis.score = interestingness(vis, ldf)
File "C:\ProgramData\Anaconda3\lib\site-packages\lux\interestingness\interestingness.py", line 149, in interestingness
chi2_score = chi2_contingency(contingency_table)[0] * 0.9 ** (
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\contingency.py", line 241, in chi2_contingency
observed = np.asarray(observed)
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\_asarray.py", line 85, in asarray
return array(a, dtype, copy=False, order=order)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\series.py", line 882, in __getitem__
return self._get_value(key)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\series.py", line 990, in _get_value
loc = self.index.get_loc(label)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 2900, in get_loc
raise KeyError(key) from err
KeyError: 0

# Fixed code
def __init__(self, intent, source=None, title="", score=0.0):
    self._intent = intent  # user's original intent to Vis
    self._inferred_intent = (
        intent  # re-written, expanded version of user's original intent
    )
    self._source = source  # original data attached to the Vis
    self._vis_data = None  # processed data for Vis (e.g., selected, aggregated, binned)
    self._code = None
    self._mark = ""
    self._min_max = {}
    self._postbin = None
    self.title = title
    self.score = score
    self.refresh_source(self._source)