简体   繁体   English

Pandas read_html object 不可调用

[英]Pandas read_html object is not callable

I'm trying to screen scrape an html table located at https://www.insidearbitrage.com/insider-sales/?desk=no using the code below.我正在尝试使用下面的代码筛选位于https://www.insidearbitrage.com/insider-sales/?desk=no的 html 表。 I'm using Python 3.9 and it's the only version of Python installed on my pc after I previously deleted other instances such as PyCharm.我正在使用 Python 3.9,它是我之前删除其他实例(例如 PyCharm)后安装在我的电脑上的唯一版本的 Python。

**import pandas as pd
from datetime import datetime
url = "https://www.insidearbitrage.com/insider-sales/?desk=no"
startTime = datetime.now()
df = pd.read_html(url)
print (df)**

But I get the following error message:但我收到以下错误消息:

Traceback (most recent call last):
  File "E:/Documents/Investing/Automation/SellsInsider_Ver2.py", line 11, in <module>
    df = pd.read_html(url)
  File "C:\Users\mseni\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\util\_decorators.py", line 299, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\mseni\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\html.py", line 1085, in read_html
    return _parse(
  File "C:\Users\mseni\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\html.py", line 918, in _parse
    ret.append(_data_to_frame(data=table, **kwargs))
  File "C:\Users\mseni\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\html.py", line 796, in _data_to_frame
    _expand_elements(body)
  File "C:\Users\mseni\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\html.py", line 769, in _expand_elements
    lens_max = lens.max()
  File "C:\Users\mseni\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\generic.py", line 11185, in max
    return NDFrame.max(self, axis, skipna, level, numeric_only, **kwargs)
  File "C:\Users\mseni\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\generic.py", line 10714, in max
    return self._stat_function(
  File "C:\Users\mseni\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\generic.py", line 10704, in _stat_function
    return self._reduce(
  File "C:\Users\mseni\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\series.py", line 4152, in _reduce
    return op(delegate, skipna=skipna, **kwds)
  File "C:\Users\mseni\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\nanops.py", line 124, in f
    result = bn_func(values, axis=axis, **kwds)
TypeError: 'NoneType' object is not callable

I can't seem to use read_html to scrape any table from any website.我似乎无法使用 read_html 从任何网站上抓取任何表格。 I have installed and re-installed Pandas as well as lxml but still get the above error.我已经安装并重新安装了 Pandas 以及 lxml,但仍然出现上述错误。 Any thoughts?有什么想法吗?

Thanks.谢谢。

After much playing around, I decided to just delete Python altogether and reinstall.在玩了很多之后,我决定完全删除 Python 并重新安装。 At one point I had multiple versions of Python on my pc including Anaconda and I had copied all site-packages from those versions into the standalone 3.9.1.有一次,我的电脑上有多个版本的 Python,包括 Anaconda,我已将所有站点包从这些版本复制到独立的 3.9.1 中。 Seems like things got pretty messed up so I uninstalled all python versions and re-installed and re-installed all packages which seems to have done the trick as this code now runs successfully.似乎事情变得一团糟,所以我卸载了所有 python 版本并重新安装并重新安装了所有似乎已经成功的软件包,因为这段代码现在运行成功。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM