In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to realize NBA player salary ranking with R data Visualization". In daily operation, I believe many people have doubts about how to realize NBA player salary ranking with R data Visualization. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about how R data Visualization can achieve NBA player salary ranking! Next, please follow the editor to study!
Import math
Import requests
From bs4 import BeautifulSoup
Headers = {"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'}
Fw = open ('NBA_salary_3.txt','w')
Fw.write ('% s\ t% s\ n%) ("year", "rk", "player", "position", "team", "salary"))
Years = list (range (2000)
For year in years:
URL = "http://www.espn.com/nba/salaries/_/year/" + str (year)
Print (URL)
Page = requests.get (URL,headers=headers)
Soup = BeautifulSoup (page.content,'html.parser')
Df = soup.find_all ('tr')
J = 0
For aa in df:
J = j + 1
If j = = 1:
Continue
Elif j > 1 and j < 12:
All_td = aa.find_all ('td')
Rk = all_td [0] .get _ text ()
Player_position = all_td [1] .get _ text ()
# print (player_position)
Player = player_position.split (",") [0]
Position = player_position.split (",") [1]
Team = all_td [2] .get _ text ()
Salary = all_td [3] .get _ text () .replace ("$", ") .replace (", ",")
Fw.write ('% s\ t% s\ n%) (str (year), rk,player,position,team,salary))
Else:
Break
Fw.close ()
First of all, let's take a look at the 2020 salary ranking top10library (ggplot2).
Ggplot (df1,aes (xymrkjime)) +
Geom_col (aes (fill=player)) +
Geom_label (aes (label=paste0 (salary, "Wan"), hjust=1)) +
Theme_bw () +
Scale_x_continuous (breaks = 1 df1 10 labels = df1 $player) +
Coord_flip () + labs (x = "", y = "") +
Theme (legend.position = "none")
Image.png then makes a dynamic bar chart.
The tool used is the gganimate package in R language.
The code used is
Df
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.