Use first row as column names? Pandas read_html

后端 未结 1 992
半阙折子戏
半阙折子戏 2021-02-14 01:50

I have this simple one line script:

from pandas import read_html

print read_html(\'http://money.cnn.com/data/hotstocks/\', flavor = \'bs4\')

W

1条回答
  •  无人及你
    2021-02-14 02:43

    'read_html` takes a header parameter. You can pass a row index:

    read_html('http://money.cnn.com/data/hotstocks/', header =0, flavor = 'bs4')
    

    Worth noting this caveat in the docs:

    For example, you might need to manually assign column names if the column names are converted to NaN when you pass the header=0 argument

    http://pandas.pydata.org/pandas-docs/stable/generated/pandas.io.html.read_html.html

    0 讨论(0)
提交回复
热议问题