1

当我练习我的可视化技能时,我偶然发现了一篇文章,

https://towardsdatascience.com/complete-guide-to-data-visualization-with-python-2dd74df12b5e

在此,此人使用了 pandas-profiling 方法,这对我来说是新的,我尝试将它用于我的数据集,但出现意外错误。

这是代码:

    import pandas_profiling
    from pandas_profiling import ProfileReport
    prof = ProfileReport(temp)
    prof.to_file(output_file='report.html')

但收到此错误:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
~\anaconda3\lib\site-packages\matplotlib\style\core.py in use(style)
    114             # rcParamsDefault, no need to reemit them here.
--> 115             with cbook._suppress_matplotlib_deprecation_warning():
    116                 _apply_style(rcParamsDefault, warn=False)

~\anaconda3\lib\site-packages\matplotlib\__init__.py in rc_params_from_file(fname, fail_on_error, use_default_template)
    795     """
--> 796     Construct a `RcParams` instance from file *fname*.
    797 

~\anaconda3\lib\site-packages\matplotlib\__init__.py in _rc_params_in_file(fname, transform, fail_on_error)
    724         with cbook._suppress_matplotlib_deprecation_warning():
--> 725             yield from sorted(dict.__iter__(self))
    726 

~\anaconda3\lib\contextlib.py in __enter__(self)
    112         try:
--> 113             return next(self.gen)
114         except StopIteration:

~\anaconda3\lib\site-packages\matplotlib\__init__.py in _open_file_or_url(fname)
    702                 from matplotlib import pyplot as plt
--> 703                 plt.switch_backend(rcsetup._auto_backend_sentinel)
    704 

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\a\\anaconda3\\lib\\site-packages\\pandas_profiling\\pandas_profiling.mplstyle'

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

OSError                                   Traceback (most recent call last)
<ipython-input-61-8913bd122e77> in <module>
      1 import pandas_profiling
      2 from pandas_profiling import ProfileReport
----> 3 prof = ProfileReport(temp)
      4 prof.to_file(output_file='report.html')

~\anaconda3\lib\site-packages\pandas_profiling\__init__.py in __init__(self, df, **kwargs)

~\anaconda3\lib\site-packages\pandas_profiling\describe.py in describe(df, bins, check_correlation, correlation_threshold, correlation_overrides, check_recoded, pool_size, **kwargs)

~\anaconda3\lib\site-packages\matplotlib\style\core.py in use(style)
    116                 _apply_style(rcParamsDefault, warn=False)
    117         elif style in library:
--> 118             _apply_style(library[style])
    119         else:
    120             try:

OSError: 'C:\\Users\\a\\anaconda3\\lib\\site-packages\\pandas_profiling\\pandas_profiling.mplstyle' not found in the style library and input is not a valid URL or path; see `style.available` for list of available styles

我不知道 mpl.style 是什么,因为检查时该位置没有任何内容。

4

2 回答 2

0

执行以下步骤:

  1. pip 卸载熊猫分析
  2. pip install pandas-profiling[笔记本]
  3. pip show pandas-profiling
于 2021-06-22T11:38:32.947 回答
0

我得到了同样的错误。这是我为解决它所做的。

注意:我使用的是 Anaconda

  • 卸载旧的pandas_profiling
  • 使用安装最新版本conda install -c conda-forge pandas-profiling=2.6.0

重要提示:不要忘记重新启动内核

于 2021-12-15T17:17:41.473 回答