首页 > 编程知识 正文

Python薪资分析

时间:2023-11-21 21:05:56 阅读:293125 作者:POQZ

Python作为一门应用广泛的编程语言,在各个行业中受到越来越多的关注。潜在的发展前景和使用便捷性吸引着越来越多的开发人员投身于这个领域。本文将从不同的角度,详细分析Python在薪资方面的表现和趋势。

一、市场需求与Python薪资关系

首先,我们来看Python在编程语言市场中的需求情况。根据TIOBE Index 2020年2月的排名,Python排名第三。


# TIOBE Index数据来源:https://www.tiobe.com/tiobe-index/
import pandas as pd
import matplotlib.pyplot as plt

url = 'https://www.tiobe.com/tiobe-index/'
tables = pd.read_html(url)
df = tables[0].iloc[:, :2]
df.columns = ['Programming Language', 'Ratings']
df['Ratings'] = df['Ratings'].apply(lambda x: float(x[:-1]))
df = df.sort_values('Ratings', ascending=False)

plt.bar(df['Programming Language'], df['Ratings'])
plt.xticks(rotation=90)
plt.xlabel('Programming Language')
plt.ylabel('Ratings')
plt.title('TIOBE Index - February 2020')
plt.show()
从图表结果可以看出,Python排名持续稳定,不断上升的趋势说明了市场对Python的青睐程度。那么Python的高需求是否反映在薪资上呢?

在Indeed.com上搜索Python相关职位,我们可以得到如下结果的爬虫代码:


import requests
from bs4 import BeautifulSoup

url = "https://www.indeed.com/jobs?q=python&l="
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')

results = soup.find(id='resultsCol')
job_elems = results.find_all('div', class_="jobsearch-SerpJobCard", limit=5)

for job_elem in job_elems:
    title_elem = job_elem.find('h2', class_='title')
    company_elem = job_elem.find('span', class_='company')
    location_elem = job_elem.find('div', class_='recJobLoc')
    salary_elem = job_elem.find('span', class_='salaryText')

    print(title_elem.text.strip())
    print(company_elem.text.strip())
    print(location_elem.text.strip())
    print(salary_elem.text.strip() if salary_elem else "Negotiable")
    print()

由以上代码的结果可以发现,Python相关的职位的薪资普遍偏高,尤其是技术要求较高的职位,薪资往往更具有吸引力。

二、Python不同职位的薪资差异

Python本身是一门通用性编程语言,可以应用于多种行业和领域。因此不同职位对Python技能的技术要求是不同的,也就导致了Python在不同职位下的薪酬水平也会有所差异。

1. Python开发工程师

Python开发工程师一般需要掌握Python基础知识、Web框架(如Django、Flask等)、SQL数据库(如MySQL、MongoDB等)、Web前端技术等各个方面的技能,而不同公司的Python开发工程师薪酬表现也会有所差异。 我们以猎聘网上Python开发工程师的薪资调查结果为例,通过如下的爬虫代码进行数据获取、预处理和简单分析:


import requests
from bs4 import BeautifulSoup
import pandas as pd
import matplotlib.pyplot as plt

url = 'https://www.liepin.com/zhaopin/?keyword=python&d_sfrom=search_fp&sortby=relevance&init=-1'
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"}
page = requests.get(url, headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')

results = soup.find_all('div', class_="job-info")

title_list, salary_list = [], []
for result in results:
    title = result.find('h3')
    salary = result.find('span', class_="text-warning")

    if title and salary:
        title_list.append(title.text.strip())
        salary_list.append(int(salary.text.replace('K', '000').replace('以上', '').replace('以下', '')))

df_salary = pd.DataFrame({
    'title': title_list,
    'salary': salary_list
})

avg_salary = round(df_salary['salary'].mean() / 1000, 1)
print(f"Python开发工程师职位的平均月薪为{avg_salary}K")

plt.boxplot(df_salary['salary'])
plt.title('Salary Distribution of Python Developer')
plt.ylabel('Salary (K)')
plt.show()

结果显示Python开发工程师职位的平均月薪约为18.5K,而薪酬分布的箱型图表明Python开发工程师的薪酬水平也有着较大的差异。

2. 数据科学家

数据科学家是需要具备Python技能的一类职位,他们一般需要对Python的数据分析和处理模块(如pandas、numpy、matplotlib等)有着深入的了解,并能够运用机器学习算法和数据挖掘技术处理数据并得出结论。 Kaggle官方在2017年发布过有关数据科学家薪酬的调查报告,根据该报告中的数据(图片来源:https://www.kaggle.com/kaggle/kaggle-survey-2017/home),我们得到如下的结果:


import pandas as pd
import matplotlib.pyplot as plt

url = 'https://raw.githubusercontent.com/Kaggle/kaggle-survey-2017/master/schema.csv'
df = pd.read_csv(url)

df_salary = df[df['CurrentJobTitleSelect']=='Data Scientist']['CompensationAmount']
df_salary = df_salary[~df_salary.isnull()].str.replace(',','').str.replace('+','').str.replace('$','').astype(float)
df_salary = df_salary[df_salary < 1000000]

avg_salary = df_salary.mean()
print(f"数据科学家职位的平均年薪为{avg_salary:.0f}美元")

plt.hist(df_salary, bins=20)
plt.title('Salary Distribution of Data Scientist')
plt.xlabel('Salary (USD)')
plt.ylabel('Frequency')
plt.show()

以上代码的结果显示,数据科学家职位的平均年薪约为13.7万美元,在数据科学家领域有着相对较高的薪酬水平。当然,具体薪资水平会受到工作地点和公司规模等因素的影响。

三、Python薪资趋势

漫长的Python发展历程中,Python在编程领域中约束性越来越小,产生出了不少Python库和高级工具。同时,在技术快速发展的当下,Python在某些领域甚至已经成为最佳解决方案。那么Python相关职位的薪资趋势如何呢?

1. Python薪资趋势回顾

我们可以通过爬去历年的Python职位薪资数据来对Python薪资的历史趋势进行观察。以拉钩网2016年、2017年和2018年Python开发工程师薪资数据为例:


import pandas as pd
import matplotlib.pyplot as plt

df_salary_2016 = pd.read_csv('data/python_salary_2016.csv')
df_salary_2017 = pd.read_csv('data/python_salary_2017.csv', encoding='gbk')
df_salary_2018 = pd.read_csv('data/python_salary_2018.csv')

plt.plot(df_salary_2016['workYear'], df_salary_2016['salaryAvg'], label='2016')
plt.plot(df_salary_2017['工作经验'], df_salary_2017['平均薪资(元/月)'], label='2017')
plt.plot(df_salary_2018['experience'], df_salary_2018['salary_k/month'], label='2018')
plt.legend()
plt.xlabel('Work Experience')
plt.ylabel('Salary (k/month)')
plt.title('Salary Trend of Python Developers - 2016~2018')
plt.show()

在2016年至2018年这段时间内,Python开发工程师的薪资呈现明显上升趋势,从平均月薪7k开始,逐步提高到2018年的18k。

2. Python薪资趋势预测

从Python近几年发展的趋势来看,Python仍在以快速的步伐向前发展。随着人工智能、云计算等热门领域的不断发生,Python的应用范围也在不断扩大。因此,Python职位的薪酬水平仍有望保持较高的水平。

四、总结

本文从市场需求、不同职位薪资差异和Python薪资趋势三个方面对Python薪酬进行了详细地阐述。通过详尽的数据调研和分析,我们可以得出Python在编程领域的地位越来越不可忽视,Python相关职位的薪资普遍较高,并且向着愈加高端化、多样化的方向发展。潜在的发展前景和丰富的应用场景,不少开发人员将Python视为必备技能之一。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。