In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.