1

我最近开始使用python。而且,我正在尝试使用 pandas_profiling 获取报告,但遇到了 IndexError。有人可以解释我如何调试这个吗?

数据有 30 个变量和大约 800,000 行。

到目前为止,我正在尝试将 csv 文件读入数据框并使用 pandas 分析对其进行分析。没有编写自定义代码[部分来自使用标准库和包。

提前致谢

import numpy as np
import pandas as pd
from pandas_profiling import ProfileReport
df_s = pd.read_csv(r'<file_path>')
ProfileReport(df_s)

Error below




---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
~\AppData\Local\Continuum\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:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas_profiling\__init__.py in _repr_html_(self)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas_profiling\__init__.py in to_widgets(self)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas_profiling\report\presentation\flavours\widget\sequence.py in render(self)
     95 
     96         elif self.sequence_type in ["tabs", "sections"]:
---> 97             widget = get_tabs(self.content["items"])
     98         elif self.sequence_type == "accordion":
     99             widget = get_accordion(self.content["items"])

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas_profiling\report\presentation\flavours\widget\sequence.py in get_tabs(items)
     16     titles = []
     17     for item in items:
---> 18         children.append(item.render())
     19         titles.append(get_name(item))
     20 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas_profiling\report\presentation\flavours\widget\sequence.py in render(self)
     97             widget = get_tabs(self.content["items"])
     98         elif self.sequence_type == "accordion":
---> 99             widget = get_accordion(self.content["items"])
    100         elif self.sequence_type == "grid":
    101             widget = get_row(self.content["items"])

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas_profiling\report\presentation\flavours\widget\sequence.py in get_accordion(items)
     59     titles = []
     60     for item in items:
---> 61         children.append(item.render())
     62         titles.append(get_name(item))
     63 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas_profiling\report\presentation\flavours\widget\preview.py in render(self)
      9         else:
     10             items = [self.content["top"]]
---> 11         return WidgetSequence(items, sequence_type="variable").render()

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas_profiling\report\presentation\flavours\widget\sequence.py in render(self)
     75         elif self.sequence_type == "variable":
     76             i1 = self.content["items"][0].render()
---> 77             i2 = self.content["items"][1].render()
     78             toggle = widgets.ToggleButton(description="Toggle details")
     79 

IndexError: list index out of range


4

1 回答 1

0

我有同样的错误,然后我减少了 df_s 的数量并且它起作用了。你可以试一试。

例子:

ProfileReport(df_s[:10000])
于 2020-03-25T06:46:25.003 回答