简体   繁体   中英

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. 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.

**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. I have installed and re-installed Pandas as well as lxml but still get the above error. Any thoughts?

Thanks.

After much playing around, I decided to just delete Python altogether and reinstall. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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