主頁 > 後端開發 > 資料科學家賺多少?基于pandasql和plotly的薪資分析與可視化 ?

資料科學家賺多少?基于pandasql和plotly的薪資分析與可視化 ?

2022-12-10 06:32:24 後端開發

?? 作者:韓信子@ShowMeAI
?? 資料分析實戰系列:https://www.showmeai.tech/tutorials/40
?? AI 崗位&攻略系列:https://www.showmeai.tech/tutorials/47
?? 本文地址:https://www.showmeai.tech/article-detail/402
?? 宣告:著作權所有,轉載請聯系平臺與作者并注明出處
?? 收藏ShowMeAI查看更多精彩內容

?? 引言

資料科學在互聯網、醫療、電信、零售、體育、航空、藝術等各個領域仍然越來越受歡迎,在 ??Glassdoor的美國最佳職位串列中,資料科學職位排名第三,2022 年有近 10,071 個職位空缺,

除了資料獨特的魅力,資料科學相關崗位的薪資也備受關注,在本篇內容中,ShowMeAI會基于資料對下述問題進行分析:

  • 資料科學中薪水最高的作業是什么?
  • 哪個國家的薪水最高,機會最多?
  • 典型的薪資范圍是多少?
  • 作業水平對資料科學家有多重要?
  • 資料科學,全職vs自由職業者
  • 資料科學領域薪水最高的作業是什么?
  • 資料科學領域平均薪水最高的作業是什么?
  • 資料科學專業的最低和最高工資
  • 招聘資料科學專業人員的公司規模如何?
  • 工資是不是跟公司規模有關?
  • WFH(遠程辦公)和 WFO 的比例是多少?
  • 資料科學作業的薪水每年如何增長?
  • 如果有人正在尋找與資料科學相關的作業,你會建議他在網上搜索什么?
  • 如果你有幾年初級員工的經驗,你應該考慮跳槽到什么規模的公司?

?? 資料說明

我們本次用到的資料集是 ??資料科學作業薪水資料集,大家可以通過 ShowMeAI 的百度網盤地址下載,

?? 實戰資料集下載(百度網盤):公眾號『ShowMeAI研究中心』回復『實戰』,或者點擊 這里 獲取本文 [37]基于pandasql和plotly的資料科學家薪資分析與可視化 『ds_salaries資料集

? ShowMeAI官方GitHub:https://github.com/ShowMeAI-Hub

資料集包含 11 列,對應的名稱和含義如下:

引數 含義
work_year 支付工資的年份
experience_level : 發薪時的經驗等級
employment_type 就業型別
job_title 崗位名稱
salary 支付的總工資總額
salary_currency 支付的薪水的貨幣
salary_in_usd 支付的標準化工資(美元)
employee_residence 員工的主要居住國家
remote_ratio 遠程完成的作業總量
company_location 雇主主要辦公室所在的國家/地區
company_size 根據員工人數計算的公司規模

本篇分析使用到Pandas和SQL,歡迎大家閱讀ShowMeAI的資料分析教程和對應的工具速查表文章,系統學習和動手實踐:

??圖解資料分析:從入門到精通系列教程

??編程語言速查表 | SQL 速查表

??資料科學工具庫速查表 | Pandas 速查表

??資料科學工具庫速查表 | Matplotlib 速查表

?? 匯入工具庫

我們先匯入需要使用的工具庫,我們使用pandas讀取資料,使用 Plotly 和 matplotlib 進行可視化,并且我們在本篇中會使用 SQL 進行資料分析,我們這里使用到了 ??pandasql 工具庫,

# For loading data
import pandas as pd
import numpy as np

# For SQL queries
import pandasql as ps

# For ploting graph / Visualization
import plotly.graph_objects as go
import plotly.express as px
from plotly.offline import iplot
import plotly.figure_factory as ff

import plotly.io as pio
import seaborn as sns
import matplotlib.pyplot as plt

# To show graph below the code or on same notebook
from plotly.offline import init_notebook_mode
init_notebook_mode(connected=True)

# To convert country code to country name
import country_converter as coco

import warnings
warnings.filterwarnings('ignore')

?? 加載資料集

我們下載的資料集是 CSV 格式的,所以我們可以使用 read_csv 方法來讀取我們的資料集,

# Loading data
salaries = pd.read_csv('ds_salaries.csv')

要查看前五個記錄,我們可以使用 salaries.head() 方法,

借助 pandasql完成同樣的任務是這樣的:

# Function query to execute SQL queries
def query(query):
 return ps.sqldf(query)

# Showing Top 5 rows of data
query("""
        SELECT * 
        FROM salaries 
        LIMIT 5
""")

輸出:

?? 資料預處理

我們資料集中的第1列“Unnamed: 0”是沒有用的,在分析之前我們把它剔除:

salaries = salaries.drop('Unnamed: 0', axis = 1)

我們查看一下資料集中缺失值情況:

salaries.isna().sum()

輸出:

work_year             0
experience_level      0
employment_type       0
job_title             0
salary                0
salary_currency       0
salary_in_usd         0
employee_residence    0
remote_ratio          0
company_location      0
company_size          0
dtype: int64

我們的資料集中沒有任何缺失值,因此不用做缺失值處理,employee_residencecompany_location 使用的是短國家代碼,我們映射替換為國家的全名以便于理解:

# Converting countries code to country names
salaries["employee_residence"] = coco.convert(names=salaries["employee_residence"], to="name")
salaries["company_location"] = coco.convert(names=salaries["company_location"], to="name")

這個資料集中的experience_level代表不同的經驗水平,使用的是如下縮寫:

  • CN: Entry Level (入門級)
  • ML:Mid level (中級)
  • SE:Senior Level (高級)
  • EX:Expert Level (資深專家級)

為了更容易理解,我們也把這些縮寫替換為全稱,

# Replacing values in column - experience_level :
salaries['experience_level'] = query("""SELECT 
                                          REPLACE(
                                            REPLACE(
                                              REPLACE(
                                                REPLACE(
                                                  experience_level, 'MI', 'Mid level'), 
                                                                    'SE', 'Senior Level'), 
                                                                    'EN', 'Entry Level'), 
                                                                    'EX', 'Expert Level') 
                                        FROM 
                                          salaries""")

同樣的方法,我們對作業形式也做全稱替換

  • FT: Full Time (全職)
  • PT: Part Time (兼職)
  • CT:Contract (合同制)
  • FL:Freelance (自由職業)
# Replacing values in column - experience_level :
salaries['employment_type'] = query("""SELECT 
                                          REPLACE(
                                            REPLACE(
                                              REPLACE(
                                                REPLACE(
                                                  employment_type, 'PT', 'Part Time'), 
                                                                    'FT', 'Full Time'), 
                                                                    'FL', 'Freelance'), 
                                                                    'CT', 'Contract') 
                                        FROM 
                                          salaries""")

資料集中公司規模欄位處理如下:

  • S:Small (小型)
  • M:Medium (中型)
  • L:Large (大型)
# Replacing values in column - company_size :
salaries['company_size'] = query("""SELECT 
                                       REPLACE(
                                         REPLACE(
                                           REPLACE(
                                             company_size, 'M', 'Medium'), 
                                                           'L', 'Large'), 
                                                           'S', 'Small') 
                                    FROM 
                                       salaries""")

我們對遠程比率欄位也做一些處理,以便更好理解

# Replacing values in column - remote_ratio :
salaries['remote_ratio'] = query("""SELECT 
                                        REPLACE(
                                          REPLACE(
                                            REPLACE(
                                              remote_ratio, '100', 'Fully Remote'), 
                                                            '50', 'Partially Remote'), 
                                                            '0', 'Non Remote Work') 
                                    FROM 
                                      salaries""")

這是預處理后的最終輸出,

?? 資料分析&可視化

?? 資料科學中薪水最高的作業是什么?

top10_jobs = query("""
                    SELECT job_title,
                    Count(*) AS job_count
                    FROM salaries
                    GROUP BY job_title
                    ORDER BY job_count DESC
                    LIMIT 10
""")

我們繪制條形圖以便更直觀理解:

data = https://www.cnblogs.com/showmeai/p/go.Bar(x = top10_jobs['job_title'], y = top10_jobs['job_count'],
             text = top10_jobs['job_count'], textposition = 'inside',
             textfont = dict(size = 12,
                            color = 'white'),
             marker = dict(color = px.colors.qualitative.Alphabet,
                          opacity = 0.9,
                          line_color = 'black',
                          line_width = 1))


layout = go.Layout(title = {'text': "<b>Top 10 Data Science Jobs</b>", 
                            'x':0.5, 'xanchor': 'center'},
                   xaxis = dict(title = '<b>Job Title</b>', tickmode = 'array'),
                   yaxis = dict(title = '<b>Total</b>'),
                   width = 900,
                   height = 600)


fig = go.Figure(data = https://www.cnblogs.com/showmeai/p/data, layout = layout)
fig.update_layout(plot_bgcolor ='#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 資料科學職位的市場分布

fig = px.pie(top10_jobs, values='job_count', 
              names='job_title', 
              color_discrete_sequence = px.colors.qualitative.Alphabet)


fig.update_layout(title = {'text': "<b>Distribution of job positions</b>", 
                            'x':0.5, 'xanchor': 'center'},
                   width = 900,
                   height = 600)

fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 擁有最多資料科學作業的國家

top10_com_loc = query("""
                    SELECT company_location AS company,
                    Count(*) AS job_count
                    FROM salaries
                    GROUP BY company
                    ORDER BY job_count DESC
                    LIMIT 10
""")


data = https://www.cnblogs.com/showmeai/p/go.Bar(x = top10_com_loc['company'], y = top10_com_loc['job_count'],
             textfont = dict(size = 12,
                            color = 'white'),
             marker = dict(color = px.colors.qualitative.Alphabet,
                          opacity = 0.9,
                          line_color = 'black',
                          line_width = 1))


layout = go.Layout(title = {'text': "<b>Top 10 Data Science Countries</b>", 
                            'x':0.5, 'xanchor': 'center'},
                   xaxis = dict(title = '<b>Countries</b>', tickmode = 'array'),
                   yaxis = dict(title = '<b>Total</b>'),
                   width = 900,
                   height = 600)


fig = go.Figure(data = https://www.cnblogs.com/showmeai/p/data, layout = layout)
fig.update_layout(plot_bgcolor ='#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

從上圖中,我們可以看出美國在資料科學方面的作業機會最多,現在我們來看看世界各地的薪水,大家可以繼續運行代碼,查看可視化結果,

df = salaries
df["company_country"] = coco.convert(names = salaries["company_location"], to = 'name_short')

temp_df = df.groupby('company_country')['salary_in_usd'].sum().reset_index()
temp_df['salary_scale'] = np.log10(df['salary_in_usd'])


fig = px.choropleth(temp_df, locationmode = 'country names', locations = "company_country",
                   color = "salary_scale", hover_name = "company_country",
                   hover_data = https://www.cnblogs.com/showmeai/p/temp_df[['salary_in_usd']], 
                    color_continuous_scale = 'Jet',
                   )


fig.update_layout(title={'text':'<b>Salaries across the World</b>', 
                         'xanchor': 'center','x':0.5})
fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 平均工資(基于貨幣計算)

df = salaries[['salary_currency','salary_in_usd']].groupby(['salary_currency'], as_index = False).mean().set_index('salary_currency').reset_index().sort_values('salary_in_usd', ascending = False)

#Selecting top 14
df = df.iloc[:14]
fig = px.bar(df, x = 'salary_currency',
            y = 'salary_in_usd',
            color = 'salary_currency',
            color_discrete_sequence = px.colors.qualitative.Safe,
            )

fig.update_layout(title={'text':'<b>Average salary as a function of currency</b>', 
                         'xanchor': 'center','x':0.5},
                 xaxis_title = '<b>Currency</b>',
                 yaxis_title = '<b>Mean Salary</b>')
fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

人們以美元賺取的收入最多,其次是瑞士法郎和新加坡元,

df = salaries[['company_country','salary_in_usd']].groupby(['company_country'], as_index = False).mean().set_index('company_country').reset_index().sort_values('salary_in_usd', ascending = False)


#Selecting top 14
df = df.iloc[:14]
fig = px.bar(df, x = 'company_country',
            y = 'salary_in_usd',
            color = 'company_country',
            color_discrete_sequence = px.colors.qualitative.Dark2,
            )


fig.update_layout(title = {'text': "<b>Average salary as a function of company location</b>", 
                            'x':0.5, 'xanchor': 'center'},
                   xaxis = dict(title = '<b>Company Location</b>', tickmode = 'array'),
                   yaxis = dict(title = '<b>Mean Salary</b>'),
                   width = 900,
                   height = 600)


fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 資料科學作業經驗水平分布

job_exp = query("""
            SELECT experience_level, Count(*) AS job_count
            FROM salaries
            GROUP BY experience_level
            ORDER BY job_count ASC
""")



data = https://www.cnblogs.com/showmeai/p/go.Bar(x = job_exp['job_count'], y = job_exp['experience_level'],
              orientation = 'h', text = job_exp['job_count'],
             marker = dict(color = px.colors.qualitative.Alphabet,
                          opacity = 0.9,
                          line_color = 'white',
                          line_width = 2))


layout = go.Layout(title = {'text': "<b>Jobs on Experience Levels</b>",
                           'x':0.5, 'xanchor':'center'},
                  xaxis = dict(title='<b>Total</b>', tickmode = 'array'),
                  yaxis = dict(title='<b>Experience lvl</b>'),
                  width = 900,
                  height = 600)

fig = go.Figure(data = https://www.cnblogs.com/showmeai/p/data, layout = layout)
fig.update_layout(plot_bgcolor ='#f1e7d2', 
                  paper_bgcolor = '#f1e7d2')
fig.show()

從上圖可以看出,大多數資料科學都是 高級水平專家級很少,

?? 資料科學作業就業型別分布

job_emp = query("""
SELECT employment_type,
COUNT(*) AS job_count
FROM salaries
GROUP BY employment_type
ORDER BY job_count ASC
""")


data =  https://www.cnblogs.com/showmeai/p/go.Bar(x = job_emp['job_count'], y = job_emp['employment_type'], 
               orientation ='h',text = job_emp['job_count'],
               textposition ='outside',
               marker = dict(color = px.colors.qualitative.Alphabet,
                             opacity = 0.9,
                             line_color = 'white',
                             line_width = 2))


layout = go.Layout(title = {'text': "<b>Jobs on Employment Type</b>",
                           'x':0.5, 'xanchor': 'center'},
                   xaxis = dict(title='<b>Total</b>', tickmode = 'array'),
                   yaxis =dict(title='<b>Emp Type lvl</b>'),
                   width = 900,
                   height = 600)


fig = go.Figure(data = https://www.cnblogs.com/showmeai/p/data, layout = layout)
fig.update_layout(plot_bgcolor ='#f1e7d2', 
                  paper_bgcolor = '#f1e7d2')
fig.show()

從上圖中,我們可以看到大多數資料科學家從事 全職作業而合同工和自由職業者 則較少

?? 資料科學作業數量趨勢

job_year = query("""
    SELECT work_year, COUNT(*) AS 'job count'
    FROM salaries
    GROUP BY work_year
    ORDER BY 'job count' DESC
""")


data = https://www.cnblogs.com/showmeai/p/go.Scatter(x = job_year['work_year'], y = job_year['job count'],
                  marker = dict(size = 20,
                                line_width = 1.5,
                                line_color = 'white',
                                color = px.colors.qualitative.Alphabet),
                  line = dict(color = '#ED7D31', width = 4), mode = 'lines+markers')


layout  = go.Layout(title = {'text' : "<b><i>Data Science jobs Growth (2020 to 2022)</i></b>",
                             'x' : 0.5, 'xanchor' : 'center'},
                    xaxis = dict(title = '<b>Year</b>'),
                    yaxis = dict(title = '<b>Jobs</b>'),
                    width = 900,
                    height = 600)


fig = go.Figure(data = https://www.cnblogs.com/showmeai/p/data, layout = layout)
fig.update_xaxes(tickvals = ['2020','2021','2022'])
fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 資料科學作業薪水分布

salary_usd = query("""
                    SELECT salary_in_usd 
                    FROM salaries
""")


import matplotlib.pyplot as plt

plt.figure(figsize = (20, 8))
sns.set(rc = {'axes.facecolor' : '#f1e7d2',
             'figure.facecolor' : '#f1e7d2'})

p = sns.histplot(salary_usd["salary_in_usd"], 
                kde = True, alpha = 1, fill = True,
                edgecolor = 'black', linewidth = 1)
p.axes.lines[0].set_color("orange")
plt.title("Data Science Salary Distribution \n", fontsize = 25)
plt.xlabel("Salary", fontsize = 18)
plt.ylabel("Count", fontsize = 18)
plt.show()

?? 薪酬最高的 10 大資料科學作業

salary_hi10 = query("""
    SELECT job_title,
    MAX(salary_in_usd) AS salary
    FROM salaries
    GROUP BY salary
    ORDER BY salary DESC
    LIMIT 10
""")

data = https://www.cnblogs.com/showmeai/p/go.Bar(x = salary_hi10['salary'],
             y = salary_hi10['job_title'],
             orientation = 'h',
             text = salary_hi10['salary'],
             textposition = 'inside',
             insidetextanchor = 'middle',
              textfont = dict(size = 13,
                             color = 'black'),
              marker = dict(color = px.colors.qualitative.Alphabet,
                           opacity = 0.9,
                           line_color = 'black',
                           line_width = 1))

layout = go.Layout(title = {'text': "<b>Top 10 Highest paid Data Science Jobs</b>",
                           'x':0.5,
                           'xanchor': 'center'},
                   xaxis = dict(title = '<b>salary</b>', tickmode = 'array'),
                   yaxis = dict(title = '<b>Job Title</b>'),
                   width = 900,
                   height = 600)
fig = go.Figure(data = https://www.cnblogs.com/showmeai/p/data, layout
                = layout)
fig.update_layout(plot_bgcolor ='#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

首席資料工程師 是資料科學領域的高薪作業,

?? 不同崗位平均薪資與排名

salary_av10 = query("""
    SELECT job_title,
    ROUND(AVG(salary_in_usd)) AS salary
    FROM salaries
    GROUP BY job_title
    ORDER BY salary DESC
    LIMIT 10
""")

data = https://www.cnblogs.com/showmeai/p/go.Bar(x = salary_av10['salary'],
             y = salary_av10['job_title'],
             orientation = 'h',
             text = salary_av10['salary'],
             textposition = 'inside',
             insidetextanchor = 'middle',
              textfont = dict(size = 13,
                             color = 'white'),
              marker = dict(color = px.colors.qualitative.Alphabet,
                           opacity = 0.9,
                           line_color = 'white',
                           line_width = 2))

layout = go.Layout(title = {'text': "<b>Top 10 Average paid Data Science Jobs</b>",
                           'x':0.5,
                           'xanchor': 'center'},
                   xaxis = dict(title = '<b>salary</b>', tickmode = 'array'),
                   yaxis = dict(title = '<b>Job Title</b>'),
                   width = 900,
                   height = 600)
fig = go.Figure(data = https://www.cnblogs.com/showmeai/p/data, layout = layout)
fig.update_layout(plot_bgcolor ='#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 資料科學薪資趨勢

salary_year = query("""
    SELECT ROUND(AVG(salary_in_usd)) AS salary,
    work_year AS year
    FROM salaries
    GROUP BY year
    ORDER BY salary DESC
""")

data = https://www.cnblogs.com/showmeai/p/go.Scatter(x = salary_year['year'],
                 y = salary_year['salary'],
                 marker = dict(size = 20,
                 line_width = 1.5,
                 line_color = 'black',
                 color = '#ED7D31'),
                 line = dict(color = 'black', width = 4), mode = 'lines+markers')

layout = go.Layout(title = {'text' : "<b>Data Science Salary Growth (2020 to 2022) </b>",
                            'x' : 0.5,
                            'xanchor' : 'center'},
                   xaxis = dict(title = '<b>Year</b>'),
                   yaxis = dict(title = '<b>Salary</b>'),
                   width = 900,
                   height = 600)


fig = go.Figure(data = https://www.cnblogs.com/showmeai/p/data, layout = layout)
fig.update_xaxes(tickvals = ['2020','2021','2022'])
fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 經驗水平&薪資

salary_exp = query("""
    SELECT experience_level AS 'Experience Level',
    salary_in_usd AS Salary
    FROM salaries
""")

fig = px.violin(salary_exp, x = 'Experience Level', y = 'Salary', color = 'Experience Level', box = True)

fig.update_layout(title = {'text': "<b>Salary on Experience Level</b>",
                            'xanchor': 'center','x':0.5},
                   xaxis = dict(title = '<b>Experience level</b>'),
                   yaxis = dict(title = '<b>salary</b>', 
                                ticktext = [-300000, 0, 100000, 200000, 300000, 400000, 500000, 600000, 700000]),
                   width = 900,
                   height = 600)

fig.update_layout(paper_bgcolor= '#f1e7d2', 
                  plot_bgcolor = '#f1e7d2', 
                  showlegend = False)
fig.show()

?? 不同經驗水平的薪資趨勢

tmp_df = salaries.groupby(['work_year', 'experience_level']).median()
tmp_df.reset_index(inplace = True)

fig = px.line(tmp_df, x='work_year', y='salary_in_usd', color='experience_level', symbol="experience_level")

fig.update_layout(title = {'text': "<b>Median Salary Trend By Experience Level</b>", 
                            'x':0.5, 'xanchor': 'center'},
                  xaxis = dict(title = '<b>Working Year</b>', tickvals = [2020, 2021, 2022], tickmode = 'array'),
                  yaxis = dict(title = '<b>Salary</b>'),
                  width = 900,
                  height = 600)

fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

觀察 1. 在COVID-19大流行期間(2020 年至 2021 年),專家級員工薪資非常高,但是呈現部分下降趨勢, 2. 2021年以后專家級和高級職稱人員工資有所上漲,

?? 年份&薪資分布

year_gp = salaries.groupby('work_year')
hist_data = https://www.cnblogs.com/showmeai/p/[year_gp.get_group(2020)['salary_in_usd'],
             year_gp.get_group(2021)['salary_in_usd'],
            year_gp.get_group(2022)['salary_in_usd']]
group_labels = ['2020', '2021', '2022']

fig = ff.create_distplot(hist_data, group_labels, show_hist = False)


fig.update_layout(title = {'text': "<b>Salary Distribution By Working Year</b>", 
                            'x':0.5, 'xanchor': 'center'},
                  xaxis = dict(title = '<b>Salary</b>'),
                  yaxis = dict(title = '<b>Kernel Density</b>'),
                  width = 900,
                  height = 600)

fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 就業型別&薪資

salary_emp = query("""
    SELECT employment_type AS 'Employment Type',
    salary_in_usd AS Salary
    FROM salaries
""")

fig = px.box(salary_emp,x='Employment Type',y='Salary',
       color = 'Employment Type')


fig.update_layout(title = {'text': "<b>Salary by Employment Type</b>", 
                            'x':0.5, 'xanchor': 'center'},
                  xaxis = dict(title = '<b>Employment Type</b>'),
                  yaxis = dict(title = '<b>Salary</b>'),
                  width = 900,
                  height = 600)

fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 公司規模分布

comp_size = query("""
                SELECT company_size,
                COUNT(*) AS count
                FROM salaries
                GROUP BY company_size
""")


import plotly.graph_objects as go
data = https://www.cnblogs.com/showmeai/p/go.Pie(labels = comp_size['company_size'], 
              values = comp_size['count'].values,
              hoverinfo = 'label',
              hole = 0.5,
              textfont_size = 16,
              textposition = 'auto')
fig = go.Figure(data = https://www.cnblogs.com/showmeai/p/data)


fig.update_layout(title = {'text': "<b>Company Size</b>", 
                            'x':0.5, 'xanchor': 'center'},
                  xaxis = dict(title = '<b></b>'),
                  yaxis = dict(title = '<b></b>'),
                  width = 900,
                  height = 600)

fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 不同公司規模的經驗水平比例

df = salaries.groupby(['company_size', 'experience_level']).size()
comp_s = np.round(df['Small'].values / df['Small'].values.sum(),2)
comp_m = np.round(df['Medium'].values / df['Medium'].values.sum(),2)
comp_l = np.round(df['Large'].values / df['Large'].values.sum(),2)

fig = go.Figure()
categories = ['Entry Level', 'Expert Level','Mid level','Senior Level']

fig.add_trace(go.Scatterpolar(
    r = comp_s,
    theta = categories,
    fill = 'toself',
    name = 'Company Size S'))

fig.add_trace(go.Scatterpolar(
    r = comp_m,
    theta = categories,
    fill = 'toself',
    name = 'Company Size M'))

fig.add_trace(go.Scatterpolar(
    r = comp_l,
    theta = categories,
    fill = 'toself',
    name = 'Company Size L'))

fig.update_layout(
    polar = dict(
    radialaxis = dict(range = [0, 0.6])),
    showlegend = True,
)


fig.update_layout(title = {'text': "<b>Proportion of Experience Level In Different Company Sizes</b>", 
                            'x':0.5, 'xanchor': 'center'},
                  xaxis = dict(title = '<b></b>'),
                  yaxis = dict(title = '<b></b>'),
                  width = 900,
                  height = 600)

fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 不同公司規模&作業薪資

salary_size = query("""
    SELECT company_size AS 'Company size',
    salary_in_usd AS Salary
    FROM salaries
""")

fig = px.box(salary_size, x='Company size', y = 'Salary',
             color = 'Company size')



fig.update_layout(title = {'text': "<b>Salary by Company size</b>", 
                            'x':0.5, 'xanchor': 'center'},
                  xaxis = dict(title = '<b>Company size</b>'),
                  yaxis = dict(title = '<b>Salary</b>'),
                  width = 900,
                  height = 600)

fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? WFH(遠程辦公)和 WFO 的比例

rem_type = query("""
    SELECT remote_ratio,
    COUNT(*) AS total
    FROM salaries
    GROUP BY remote_ratio
""")


data = https://www.cnblogs.com/showmeai/p/go.Pie(labels = rem_type['remote_ratio'], values = rem_type['total'].values,
             hoverinfo = 'label',
             hole = 0.4,
             textfont_size = 18,
             textposition = 'auto')

fig = go.Figure(data = https://www.cnblogs.com/showmeai/p/data)

fig.update_layout(title = {'text': "<b>Remote Ratio</b>", 
                            'x':0.5, 'xanchor': 'center'},
                  width = 900,
                  height = 600)

fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 薪水受Remote Type影響程度

salary_remote = query("""
    SELECT remote_ratio AS 'Remote type',
    salary_in_usd AS Salary
    From salaries
""")

fig = px.box(salary_remote, x = 'Remote type', y = 'Salary', color = 'Remote type')



fig.update_layout(title = {'text': "<b>Salary by Remote Type</b>", 
                            'x':0.5, 'xanchor': 'center'},
                  xaxis = dict(title = '<b>Remote type</b>'),
                  yaxis = dict(title = '<b>Salary</b>'),
                  width = 900,
                  height = 600)

fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 不同經驗水平&遠程比率

exp_remote = salaries.groupby(['experience_level', 'remote_ratio']).count()
exp_remote.reset_index(inplace = True)

fig = px.histogram(exp_remote, x = 'experience_level',
                  y = 'work_year', color = 'remote_ratio',
                  barmode = 'group',
                  text_auto = True)


fig.update_layout(title = {'text': "<b>Respondent Count In Different Experience Level Based on Remote Ratio</b>", 
                            'x':0.5, 'xanchor': 'center'},
                  xaxis = dict(title = '<b>Experience Level</b>'),
                  yaxis = dict(title = '<b>Number of Respondents</b>'),
                  width = 900,
                  height = 600)

fig.update_layout(plot_bgcolor = '#f1e7d2',
                 paper_bgcolor = '#f1e7d2')
fig.show()

?? 分析結論

  • 資料科學領域Top3多的職位是資料科學家資料工程師資料分析師

  • 資料科學作業越來越受歡迎,員工比例從2020年的11.9%增加到2022年的52.4%

  • 美國是資料科學公司最多的國家,

  • 工資分布的IQR在62.7k和150k之間,

  • 在資料科學員工中,大多數是高級水平,而專家級則更少,

  • 大多數資料科學員工都是全職作業,很少有合同工自由職業者

  • 首席資料工程師是薪酬最高的資料科學作業,

  • 資料科學的最低工資(入門級經驗)為4000美元,具有專家級經驗的資料科學的最高工資為60萬美元,

  • 公司構成:53.7%中型公司,32.6%大型公司,13.7%小型資料科學公司,

  • 工資也受公司規模影響,規模大的公司支付更高的薪水,

  • 62.8%的資料科學是完全遠程作業,20.9%是非遠程作業,16.3%部分遠程作業,

  • 資料科學薪水隨時間和經驗積累而增長

參考資料

  • ?? Glassdoor
  • ?? pandasql
  • ?? 資料科學作業薪水資料集(Kaggle)
  • ?? 圖解資料分析:從入門到精通系列教程:https://www.showmeai.tech/tutorials/33
  • ?? 編程語言速查表 | SQL 速查表:https://www.showmeai.tech/article-detail/99
  • ?? 資料科學工具庫速查表 | Pandas 速查表:https://www.showmeai.tech/article-detail/101
  • ?? 資料科學工具庫速查表 | Matplotlib 速查表:https://www.showmeai.tech/article-detail/103

推薦閱讀

  • ?? 資料分析實戰系列 :https://www.showmeai.tech/tutorials/40
  • ?? 機器學習資料分析實戰系列:https://www.showmeai.tech/tutorials/41
  • ?? 深度學習資料分析實戰系列:https://www.showmeai.tech/tutorials/42
  • ?? TensorFlow資料分析實戰系列:https://www.showmeai.tech/tutorials/43
  • ?? PyTorch資料分析實戰系列:https://www.showmeai.tech/tutorials/44
  • ?? NLP實戰資料分析實戰系列:https://www.showmeai.tech/tutorials/45
  • ?? CV實戰資料分析實戰系列:https://www.showmeai.tech/tutorials/46
  • ?? AI 面試題庫系列:https://www.showmeai.tech/tutorials/48

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/539600.html

標籤:Python

上一篇:利用Python實作批量ping的小工具

下一篇:python基礎-常用內置包

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more