Python - excel export

前端 未结 2 1538
隐瞒了意图╮
隐瞒了意图╮ 2020-12-12 01:51

I\'ve got this code:

import pandas as pd
import requests
from bs4 import BeautifulSoup

res = requests.get(\"https://www.bankier.pl/gielda/notowania/akcje\")         


        
相关标签:
2条回答
  • 2020-12-12 02:17

    From the pandas.read_html documentation: Read HTML tables into a list of DataFrame objects.

    So, df is a list of dataframes. If you expect to only have one, it may be safe for you to use df[0].to_excel...

    0 讨论(0)
  • 2020-12-12 02:27

    pd.read_html returns a list of dataframes, you need to use an indexer to get the first dataframe.

    Use:

    df = pd.read_html(str(table))[0]
    
    0 讨论(0)
提交回复
热议问题