I am learning to web scrape using MLB data. I would just like the team and the WAR data. I am not sure how to parse only the data that I am looking for. I do not desire the team record or the parenthesis. Any help would be greatly appreciated.
My hope is to create a Pandas DataFrame with the desired output.
Data needed: 1) Team 2))WAR
Desired data format(below):
Team WAR
ARI 1.3
ATL 1.87
BAL 2.60
BOS .43
import pandas as pd
url = 'https://www.baseball-reference.com/leagues/MLB/2020-team-starting-lineups.shtml'
test = pd.read_html(url)
for t in test:
team = t['Tm']
print(team)
I am not sure how to parse out the extra data. Thanks in advance for your time and suggestions. =)
