pandas_profiling TypeError when using HTML format

1k Views Asked by At

I follow the pandas_profiling document script, but this problem always arises. My dataset is the boston from sklearn.

I have the report, but without the features of an html version:

profile2 = ProfileReport(data, title="Relatório DATASET -data-", html={'style': {'full_width': True}}, sort="None")

The image below refers to this code:

 from pandas_profiling import ProfileReport    
 profile = ProfileReport(data, title='Pandas Profiling Report', explorative=True)

[![enter image description here][1]][1]

My version of pandas_profiling [![enter image description here][2]][2]

I don't have the problem related above if I use this code:

profile = ProfileReport (data)

UPDATE: Uninstalled the previous version and got the new one (2.9.0), but this problems happens:

  Summarize dataset: 75%
21/28 [00:07<00:02, 2.84it/s, Get scatter matrix]

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
    343             method = get_real_method(obj, self.print_method)
    344             if method is not None:
--> 345                 return method()
    346             return None
    347         else:

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in _repr_html_(self)
    407     def _repr_html_(self):
    408         """The ipython notebook widgets user interface gets called by the jupyter notebook."""
--> 409         self.to_notebook_iframe()
    410 
    411     def __repr__(self):

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in to_notebook_iframe(self)
    387         with warnings.catch_warnings():
    388             warnings.simplefilter("ignore")
--> 389             display(get_notebook_iframe(self))
    390 
    391     def to_widgets(self):

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\report\presentation\flavours\widget\notebook.py in get_notebook_iframe(profile)
     63         output = get_notebook_iframe_src(profile)
     64     elif attribute == "srcdoc":
---> 65         output = get_notebook_iframe_srcdoc(profile)
     66     else:
     67         raise ValueError(

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\report\presentation\flavours\widget\notebook.py in get_notebook_iframe_srcdoc(profile)
     21     width = config["notebook"]["iframe"]["width"].get(str)
     22     height = config["notebook"]["iframe"]["height"].get(str)
---> 23     src = html.escape(profile.to_html())
     24 
     25     iframe = f'<iframe width="{width}" height="{height}" srcdoc="{src}" frameborder="0" allowfullscreen></iframe>'

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in to_html(self)
    357 
    358         """
--> 359         return self.html
    360 
    361     def to_json(self) -> str:

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in html(self)
    177     def html(self):
    178         if self._html is None:
--> 179             self._html = self._render_html()
    180         return self._html
    181 

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in _render_html(self)
    284         from pandas_profiling.report.presentation.flavours import HTMLReport
    285 
--> 286         report = self.report
    287 
    288         disable_progress_bar = not config["progress_bar"].get(bool)

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in report(self)
    171     def report(self):
    172         if self._report is None:
--> 173             self._report = get_report_structure(self.description_set)
    174         return self._report
    175 

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in description_set(self)
    152     def description_set(self):
    153         if self._description_set is None:
--> 154             self._description_set = describe_df(self.title, self.df, self._sample)
    155         return self._description_set
    156 

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\model\describe.py in describe(title, df, sample)
    100         # Scatter matrix
    101         pbar.set_postfix_str("Get scatter matrix")
--> 102         scatter_matrix = get_scatter_matrix(df, variables)
    103         pbar.update()
    104 

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\model\summary.py in get_scatter_matrix(df, variables)
    696             for y in continuous_variables:
    697                 if x in continuous_variables:
--> 698                     scatter_matrix[x][y] = scatter_pairwise(df[x], df[y], x, y)
    699     else:
    700         scatter_matrix = {}

C:\ProgramData\Anaconda3\lib\contextlib.py in inner(*args, **kwds)
     71         @wraps(func)
     72         def inner(*args, **kwds):
---> 73             with self._recreate_cm():
     74                 return func(*args, **kwds)
     75         return inner

C:\ProgramData\Anaconda3\lib\contextlib.py in __enter__(self)
    110         del self.args, self.kwds, self.func
    111         try:
--> 112             return next(self.gen)
    113         except StopIteration:
    114             raise RuntimeError("generator didn't yield") from None

C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\visualisation\context.py in manage_matplotlib_context()
     77         register_matplotlib_converters()
     78         matplotlib.rcParams.update(customRcParams)
---> 79         sns.set_style(style="white")
     80         yield
     81     finally:

AttributeError: module 'seaborn' has no attribute 'set_style'
1

There are 1 best solutions below

0
On

The solution was unistall / reinstall the Anaconda and the pandas-profiling. Probably some version issue as suggested by Paul H on the comments.