2

我按照 pandas_profiling 文档脚本,但是这个问题总是出现。我的数据集是来自 sklearn 的 boston。

我有报告,但没有 html 版本的功能:

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

下图参考了这段代码:

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

[![在此处输入图像描述][1]][1]

我的 pandas_profiling 版本 [![在此处输入图像描述][2]][2]

如果我使用此代码,则没有上述相关问题:

profile = ProfileReport (data)

更新: 卸载了以前的版本并获得了新版本(2.9.0),但是会出现这个问题:

  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'
4

1 回答 1

1

解决方案是卸载/重新安装 Anaconda 和 pandas-profiling。可能是 Paul H 在评论中建议的一些版本问题。

于 2020-09-17T19:59:08.440 回答