我試着用熊貓讀取ec2定價表格。基於documentation我期望DataFrames的列表,但得到一個表作爲列表。pandas.read_html只返回一個表格
代碼示例
import pandas
link = 'http://aws.amazon.com/ec2/pricing/'
data = pandas.read_html(link)
print type(data)
print data[0]
輸出
<type 'list'>
0 1 2
0 Reserved Instance Volume Discounts NaN NaN
1 Total Reserved Instances Upfront Discount Hourly Discount
2 Less than $250,000 0% 0%
3 $250,000 to $2,000,000 5% 5%
4 $2,000,000 to $5,000,000 10% 10%
5 More than $5,000,000 Contact Us Contact Us
環境:
- Ubuntu的14.10 只
- 蟒蛇2.7.8
- 大熊貓0.14.1
什麼'類型(數據[0])'?你鏈接的文檔'read_html'將返回一個DataFrames列表,這就是你得到的:一個包含1個DataFrame的列表。通過檢查源代碼,它看起來像是唯一真正的HTML表(在tr URL中使用'tr','td')是預留實例卷折扣。 – wflynny 2014-11-24 20:55:29