pands returns the element with the most occurrences in a column (that is, returns the index corresponding to the maximum value in the series structure after the value_counts() counts the number)

Business scene:

Recruitment data exploration and analysis
1. Read the data and save it as a data frame named job_info.
2. Name the column as: ['Company','Position','Work Location','Salary','Release Date].
3. Which position has the most demand for recruitment?
4. Take out the recruitment information released on September 3.
5. Find out the recruitment information of data analysts whose work place is in Shenzhen.

        The third question is which position has the most demand for recruitment? First use value_counts() to count the number of occurrences of each element in the post column, and the return result is Series

       

Insert picture description here

       

Core code

goal = Series.idxmax()

       

Example

import pandas as pd

job_info = pd.read_csv('job_info.csv',header=None,names=('公司','岗位','工作地点','工资','发布日期'),encoding = 'gbk')
a = job_info.loc[:,'岗位'].value_counts()   #统计岗位这一列每个元素出现的个数
b = a.idxmax()  # 找出招聘需求最多的岗位
data_9_3 = job_info[job_info['发布日期'] == '09-03']    # 取出9月3日的招聘信息
data5 = job_info[(job_info['工作地点'] == '深圳') & (job_info['岗位'] == '数据分析师')]   #找出工作地点在深圳的数据分析师招聘信息

Guess you like

Origin blog.csdn.net/qq_43657442/article/details/109010161