Repository: deepchecks/deepchecks

Issue:
[BUG]  Top Trust Score Samples produces an error
**Describe the bug**
The `Top Trust Score Samples` check produces an error. The full stack trace of the error is attached below.

**To Reproduce**
Checkout my `urlnb` branch, which is up-to-date with `main` at the moment of opening this issue, and run the `deepchecks/deepchecks/docs/source/examples/use-cases/phishing_urls.ipynb` notebook.

The full stack trace of the error is attached below.

**Expected behavior**
The `Top Trust Score Samples` check should render correctly, as it did up until now.

**Screenshots**
If applicable, add screenshots to help explain your problem.
![image](https://user-images.githubusercontent.com/917954/149194436-bd5fbee7-1f4c-4d6d-86cd-0eb105f68436.png)
![image](https://user-images.githubusercontent.com/917954/149194477-9ca2dbe1-db5c-4224-b738-8d50d62e9045.png)


**Environment (please complete the following information):**
 - OS: macOS Big Sur 11.6.1 
 - Python Version: 3.8.5
 - Deepchecks Version: Latest commit on the `urlnb` branch.

**Additional context**
Log here:
```python
Top Trust Score Samples
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/.pyenv/versions/3.8.5/envs/py3/lib/python3.8/site-packages/IPython/core/formatters.py in __call__(self, obj)
    916             method = get_real_method(obj, self.print_method)
    917             if method is not None:
--> 918                 method()
    919                 return True
    920 

~/clones/deepchecks/deepchecks/base/suite.py in _ipython_display_(self)
     42 
     43     def _ipython_display_(self):
---> 44         display_suite_result(self.name, self.results)
     45 
     46     def show(self):

~/clones/deepchecks/deepchecks/base/display_suite.py in display_suite_result(suite_name, results)
    140     if display_table:
    141         for i, r in enumerate(display_table):
--> 142             r.show(show_conditions=False, unique_id=unique_id)
    143             if i < len(display_table) - 1:
    144                 display_html(light_hr, raw=True)

~/clones/deepchecks/deepchecks/base/check.py in show(self, show_conditions, unique_id)
    173         """Display check result."""
    174         if is_ipython_display():
--> 175             self._ipython_display_(show_conditions=show_conditions, unique_id=unique_id)
    176         else:
    177             print(self)

~/clones/deepchecks/deepchecks/base/check.py in _ipython_display_(self, show_conditions, unique_id)
    103         for item in self.display:
    104             if isinstance(item, (pd.DataFrame, Styler)):
--> 105                 display_dataframe(item)
    106             elif isinstance(item, str):
    107                 display_html(item, raw=True)

~/clones/deepchecks/deepchecks/base/display_pandas.py in display_dataframe(df)
     29         df (Union[pd.DataFrame, Styler]): Dataframe to display
     30     """
---> 31     display_html(dataframe_to_html(df), raw=True)
     32 
     33 

~/clones/deepchecks/deepchecks/base/display_pandas.py in dataframe_to_html(df)
     53         # https://developer.mozilla.org/en-US/docs/Web/CSS/white-space#values
     54         df_styler.set_properties(**{'white-space': 'pre-wrap'})
---> 55         return df_styler.render()
     56     # Because of MLC-154. Dataframe with Multi-index or non unique indices does not have a style
     57     # attribute, hence we need to display as a regular pd html format.

~/.pyenv/versions/3.8.5/envs/py3/lib/python3.8/site-packages/pandas/io/formats/style.py in render(self, sparse_index, sparse_columns, **kwargs)
    270         if sparse_columns is None:
    271             sparse_columns = get_option("styler.sparse.columns")
--> 272         return self._render_html(sparse_index, sparse_columns, **kwargs)
    273 
    274     def set_tooltips(

~/.pyenv/versions/3.8.5/envs/py3/lib/python3.8/site-packages/pandas/io/formats/style_render.py in _render_html(self, sparse_index, sparse_columns, **kwargs)
    119         Generates a dict with necessary kwargs passed to jinja2 template.
    120         """
--> 121         self._compute()
    122         # TODO: namespace all the pandas keys
    123         d = self._translate(sparse_index, sparse_columns)

~/.pyenv/versions/3.8.5/envs/py3/lib/python3.8/site-packages/pandas/io/formats/style_render.py in _compute(self)
    158         r = self
    159         for func, args, kwargs in self._todo:
--> 160             r = func(self)(*args, **kwargs)
    161         return r
    162 

~/.pyenv/versions/3.8.5/envs/py3/lib/python3.8/site-packages/pandas/io/formats/style.py in _applymap(self, func, subset, **kwargs)
   1171         subset = non_reducing_slice(subset)
   1172         result = self.data.loc[subset].applymap(func)
-> 1173         self._update_ctx(result)
   1174         return self
   1175 

~/.pyenv/versions/3.8.5/envs/py3/lib/python3.8/site-packages/pandas/io/formats/style.py in _update_ctx(self, attrs)
    953         """
    954         if not self.index.is_unique or not self.columns.is_unique:
--> 955             raise KeyError(
    956                 "`Styler.apply` and `.applymap` are not compatible "
    957                 "with non-unique index or columns."

KeyError: '`Styler.apply` and `.applymap` are not compatible with non-unique index or columns.'

Model Evaluation Suite
```



Discussion:

Resolving patch:
diff --git a/deepchecks/base/display_pandas.py b/deepchecks/base/display_pandas.py
--- a/deepchecks/base/display_pandas.py
+++ b/deepchecks/base/display_pandas.py
@@ -47,11 +47,11 @@ def dataframe_to_html(df: Union[pd.DataFrame, Styler]):
             warnings.simplefilter(action='ignore', category=FutureWarning)
             df_styler.set_precision(2)
 
-        # Align everything to the left
-        df_styler.set_table_styles([dict(selector='table,thead,tbody,th,td', props=[('text-align', 'left')])])
-        # Define how to handle white space characters (like \n)
-        # https://developer.mozilla.org/en-US/docs/Web/CSS/white-space#values
-        df_styler.set_properties(**{'white-space': 'pre-wrap'})
+        table_css_props = [
+            ('text-align', 'left'),  # Align everything to the left
+            ('white-space', 'pre-wrap')  # Define how to handle white space characters (like \n)
+        ]
+        df_styler.set_table_styles([dict(selector='table,thead,tbody,th,td', props=table_css_props)])
         return df_styler.render()
     # Because of MLC-154. Dataframe with Multi-index or non unique indices does not have a style
     # attribute, hence we need to display as a regular pd html format.


Test patch: