简体   繁体   English

使用 HTML 格式时的 pandas_profiling TypeError

[英]pandas_profiling TypeError when using HTML format

I follow the pandas_profiling document script, but this problem always arises.我遵循pandas_profiling 文档脚本,但是这个问题总是出现。 My dataset is the boston from sklearn.我的数据集是来自 sklearn 的波士顿。

I have the report, but without the features of an html version:我有报告,但没有 html 版本的功能:

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] [![在此处输入图像描述][1]][1]

My version of pandas_profiling [![enter image description here][2]][2]我的 pandas_profiling 版本 [![在此处输入图像描述][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:更新:卸载了以前的版本并获得了新版本(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'

The solution was unistall / reinstall the Anaconda and the pandas-profiling.解决方案是卸载/重新安装 Anaconda 和 pandas-profiling。 Probably some version issue as suggested by Paul H on the comments.可能是 Paul H 在评论中建议的一些版本问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Pandas_profiling 渲染 html 报告时出现 ValueError - ValueError when rendering html report using Pandas_profiling 如何在使用 pandas_profiling 运行 ProfileReport 时解决 TypeError? - How to resolve TypeError while running ProfileReport using pandas_profiling? 使用 pandas_profiling profile_report 时出现 MemoryError - MemoryError when using pandas_profiling profile_report 使用 pandas_profiling 时:“ModuleNotFoundError:没有名为‘visions.application’的模块” - When using pandas_profiling: "ModuleNotFoundError: No module named 'visions.application'" 如何使用pandas_profiling对表进行数据配置文件 - How to do Data profile to a table using pandas_profiling 无法使用 sqlmlutils 将“pandas_profiling”添加到 SQL Server - Cannot add 'pandas_profiling' into SQL Server using sqlmlutils 使用 pandas_profiling 时 Python 中的属性错误 - Attribute error in Python while using pandas_profiling Juypter 笔记本 pandas_profiling:无法从“pandas_profiling.report”导入名称“to_html” - Juypter notebook pandas_profiling: cannot import name 'to_html' from 'pandas_profiling.report' 无法在 pandas_profiling 上显示进度条 - Unable to display progress bar on pandas_profiling Pandas Profiling - NameError:未定义名称“pandas_profiling” - Pandas Profiling - NameError: name 'pandas_profiling' is not defined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM