import urllib2
import pandas as pd
page1 = urllib2.urlopen(
'http://www.basketball-reference.com/players/h/hardeja01/gamelog/2015/').read()
#Select the correct table by some attributes, in this case id=pgl_basic.
#The read_html function returns a list of tables.
#In this case we select the first (and only) table with this id
stat_table = pd.io.html.read_html(page1,attrs={'id':'pgl_basic'})[0]
#Just select the column we needed.
point_column = stat_table['PTS']
print point_column
我建议你阅读整个表格,然后我建议你阅读整个表格。也许你会在速度上失去一些东西,但在简单中你会得到更多。在
使用pandas的read_html函数很容易做到:
如果您还不熟悉熊猫,您可以从以下内容中了解更多: http://pandas-docs.github.io/pandas-docs-travis/10min.html
例如,您可能希望从表中删除标题行或将表拆分为多个表。在
相关问题 更多 >
编程相关推荐