Search code examples
pythonpandashtml-parsing

tables = pd.read_html indexerror: list index out of range


I am trying to get dataframe out of a table from website. I got an error: Indexerror: list index out of range. Please help.

import pandas as pd
tables = pd.read_html("http://stat.legalpress.ru/stats/ug/t/11/s/1")
ren=tables[1]
ren

Solution

  • It has only 1 table and sine array/lists are 0-indexed in python you should use tables[0] instead of tables[1].

    import pandas as pd
    tables = pd.read_html("http://stat.legalpress.ru/stats/ug/t/11/s/1")
    ren=tables[0]
    ren