Python 如何附加NBA球员的名字与统计?

Python 如何附加NBA球员的名字与统计?,python,pandas,dataframe,append,concatenation,Python,Pandas,Dataframe,Append,Concatenation,我仍在学习网页抓取,可以使用一些帮助请。我想通过组合3个不同的数据框来获得每个球员的NBA球队统计数据:球员名称、球员状态1、球员状态2 下面是我正在寻找的数据帧示例: Name GP MIN PTS ... Anthony Davis 62 34.4 26.1 ... Lebron James 67 34.6 25.3 ... Kyle Kuzma 61 25.0 12.8 ..

我仍在学习网页抓取,可以使用一些帮助请。我想通过组合3个不同的数据框来获得每个球员的NBA球队统计数据:球员名称、球员状态1、球员状态2

下面是我正在寻找的数据帧示例:

Name                GP   MIN   PTS   ...

Anthony Davis       62   34.4  26.1  ...

Lebron James        67   34.6  25.3  ...

Kyle Kuzma          61   25.0  12.8  ...

...                 ...   ...   ...
以下是我目前的代码:

import pandas as pd

import requests

url = 'https://www.espn.com/nba/team/stats/_/name/lal/season/2020/seasontype/2'
df = pd.read_html(url)



#goal 1 get player names

playerNames = df[0]


#goal 2 get stats

playerStats_one = df[1]
playerStats_two = df[3]


#goal 3 append or concat player stats to player name dataframe

new_df = pd.concat([playerNames, playerStats_one, playerStats_two], ignore_index=True, sort=False)

new_df2 = playerNames.append(playerStats_one, ignore_index=True)


我尝试使用pd.concat和append选项,输出有一堆“nan”值。如有任何建议,将不胜感激。提前感谢您提供的任何见解。

pd.concat([df[0],df[1],df[3]],axis=1)
非常感谢@Quang Hoang花时间帮助我。你愿意回答这个问题吗?这样我就可以把它标为最好的答案了?不客气。快乐编码。