Pandas——value_counts&index&to_dict

本文利用Pandas分析大学专业与就业数据,涉及all-ages.csv和recent-grads.csv两个CSV文件。主要内容包括计算Major Categories的就读人数、低薪工作学生占比,以及对比两个数据集的就业率变化。
摘要由CSDN通过智能技术生成

本文数据是大学专业和就业的信息。有两个csv文件all-ages.csv和recent-grads.csv

  • 主要的属性如下:

Rank - The numerical rank of the major by post-graduation median earnings.
Major_code - The numerical code of the major.
Major - The description of the major.
Major_category - The category of the major.
Total - The total number of people who studied the major.
Men - The number of men who studied the major.
Women - The number of women who studied the major.
ShareWomen - The share of women (from 0 to 1) who studied the major.
Employed - The number of people who studied the major and were employed post-graduation.

  • recent-grads.csv
    这里写图片描述
  • all-ages.csv和这个类似,只是某些列的值不同

Summarizing Major Categories

计算两个数据集中每个Major Categories(每个Major Categories包含多个Major
)的就读的人数。

  • Series.value_counts返回的是该Series对象中独一无二的元素的个数(Returns object containing counts of unique values.)是个Series对象。
print(all_ages['Major_category'].value_counts())
'''
Engineering                            29
Education                              16
Humanities & Liberal Arts              15
Biology & Life Science                 14
Business        
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值