Pandas 需要以下查询的帮助吗

Pandas 需要以下查询的帮助吗,pandas,Pandas,我得到了这个错误: 标记数据时出错。C错误:saw 3第11行中应有2个字段 代码:导入webbrowser 网站=“” webbrowser.open(网站) 接下来是上面提到的内容。我相信您需要使用-返回所有解析的表并按位置选择Dataframe: website = 'https://en.wikipedia.org/wiki/Winning_percentage' #select first parsed table df1 = pd.read_html(website)[0] prin

我得到了这个错误:

标记数据时出错。C错误:saw 3第11行中应有2个字段

代码:导入webbrowser 网站=“” webbrowser.open(网站)

接下来是上面提到的内容。

我相信您需要使用-返回所有解析的表并按位置选择Dataframe:

website = 'https://en.wikipedia.org/wiki/Winning_percentage'
#select first parsed table
df1 = pd.read_html(website)[0]
print (df1.head())
  Win %  Wins  Losses  Year                     Team                  Comment
0  0.798    67      17  1882  Chicago White Stockings   best pre-modern season
1  0.763   116      36  1906             Chicago Cubs  best 154-game NL season
2  0.721   111      43  1954        Cleveland Indians  best 154-game AL season
3  0.716   116      46  2001         Seattle Mariners  best 162-game AL season
4  0.667   108      54  1975          Cincinnati Reds  best 162-game NL season

#select second parsed table
df2 = pd.read_html(website)[1]
print (df2)
   Win %  Wins  Losses   Season                   Team  \
0  0.890    73       9  2015–16  Golden State Warriors   
1  0.110     9      73  1972–73     Philadelphia 76ers   
2  0.106     7      59  2011–12      Charlotte Bobcats   

                      Comment  
0         best 82 game season  
1        worst 82-game season  
2  worst season statistically  

我的解决方案如何工作?
website = 'https://en.wikipedia.org/wiki/Winning_percentage'
#select first parsed table
df1 = pd.read_html(website)[0]
print (df1.head())
  Win %  Wins  Losses  Year                     Team                  Comment
0  0.798    67      17  1882  Chicago White Stockings   best pre-modern season
1  0.763   116      36  1906             Chicago Cubs  best 154-game NL season
2  0.721   111      43  1954        Cleveland Indians  best 154-game AL season
3  0.716   116      46  2001         Seattle Mariners  best 162-game AL season
4  0.667   108      54  1975          Cincinnati Reds  best 162-game NL season

#select second parsed table
df2 = pd.read_html(website)[1]
print (df2)
   Win %  Wins  Losses   Season                   Team  \
0  0.890    73       9  2015–16  Golden State Warriors   
1  0.110     9      73  1972–73     Philadelphia 76ers   
2  0.106     7      59  2011–12      Charlotte Bobcats   

                      Comment  
0         best 82 game season  
1        worst 82-game season  
2  worst season statistically