I'm doing a udemy course about Pandas, one exercise asks you to select the number of jobs mentioned once in the dataframe in the year 2013 (the dataframe contains employeename
, year
, salaries
, job title
, etc.. ) I used
sal[sal["Year"]==2013]["JobTitle"].nunique(dropna="True")
the output was 1051
the solution used value_counts()==1
sum(sal[sal['Year']==2013]['JobTitle'].value_counts() == 1)
the output is 202
If I got the basics right, I think the sum value_counts()==1
is the same as unique
but I got different outputs any help please and thanks!
sal[sal["Year"]==2013]["JobTitle"].nunique(dropna="True")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.