In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to climb the salary of NBA Lakers through Python and analyze it". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "how to climb and analyze the salary of NBA Lakers through Python".
The text and pictures of this article come from the network, only for learning, communication and use, do not have any commercial use, the copyright belongs to the original author, if you have any questions, please contact us in time to deal with.
The following NBA Lakers players' salary is crawled through Python and analyzed. The code is as follows:
1import pandas as pd 2import matplotlib.pyplot as plt 3df = pd.DataFrame () 4url_list = ['http://www.espn.com/nba/salaries/_/seasontype/4'] 5for i in range (2) 13): 6 url = 'http://www.espn.com/nba/salaries/_/page/%s/seasontype/4'% I 7 url_list.append (url) traverse the table in the web page to read the web page table data 9for url in url_list:10 df = df.append (pd.read_html (url), ignore_index=True) 1 list parsing: traversing the third column of dataframe Start with the substring $12df = df [[x.startswith ('$') for x in df [3] 1 filter "Lakers" 14df1=df [df [2] = = 'Los Angeles Lakers'] 15df2=df1.copy () # make a copy 16df2 [3] = df2 [3] .map (lambda a: a.replace (' $',')) # remove the "$" from the salary 17df2 [3] = df2 [3] .apply (lambda x: float (x.replace (",") (")) 18print (df2) adds a list of 20df2 ['Chinese name'] = ['LeBron James', 'Anthony Davis', 'Danny Green', 'Kentavius Caldwell Pop', 'Avery Bradley', 'Javier McKee', 'Devente Carcock', 'Quinn Cook', 'Alex Caruso', 'Rajan Rondo' 'Kyle Kuzma', 'Makif Morris', 'Jared Dudley', 'Dwight Howard', 'David Stockton'] 21df2.to_excel ('NBA1.xlsx',header= [' RK','NAME','TEAM','SALARY',' Chinese name'], index=False) 22df3=df2.sort_values (by=3) Ascending=True) # descending sort 23fig=plt.figure (figsize= (8Jing 4)) # canvas size 24plt.subplots_adjust (left=0.3) # adjust the blank space of the chart 25plt.rcParams ['font.sans-serif'] = [' SimHei'] # solve Chinese garbled 26plt.ticklabel_format (useOffset=False, style='plain') # prohibit scientific counting method 27plt.title ('NBA Lakers salary analysis' Fontsize='18') # Chart title 28plt.xlim ['Chinese name'] 30y=df3 [3] 31median=df3 [3] .salary () 32plt.barh () 34plt.axvline (median,color='blue',linestyle='--',) 35plt.show () 3 median salary reference line 34plt.axvline (median,color='blue',linestyle='--',) 35plt.show () above is all the content of the article "how to climb and analyze the salary of NBA Lakers players through Python" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.