4
我使用pd.read_html()
從網頁導入表,但不是將數據結構化爲數據框,而是將Python作爲列表導入。如何將數據作爲數據框導入?謝謝!pd.read_html()導入列表而不是數據框
的代碼如下:
import pandas as pd
import html5lib
url = 'http://www.fdic.gov/bank/individual/failed/banklist.html'
dfs = pd.read_html(url)
type(dfs)
Out[1]: list
謝謝!確實df是一個數據框。但是,當我嘗試Python上的.head,.tail和.index參數時,Python返回了錯誤消息。我該如何解決這個問題? – AlK
@AlexanderKonstantinidis有趣,'df.tail','df.head','df.index'適合我。你有什麼錯誤? – alecxe
AttributeError:'DataFrame'對象沒有'heads'屬性,AttributeError:'DataFrame'對象沒有'tails'屬性,TypeError:'Index'對象不可調用 – AlK