In [1]:
df.groupby('gender')['convertedcomp'].median()
Out [1]:
gender
man 910
woman 42
Name: convertedcomp, dtype: int64
#this worked in the notebook, not sure the difference in syntax between the two answers, someone might be able to shine some light on that
In [2]:
data = {'convertedcomp': [61, 951, 910, 30, 42, 899], 'gender': ['man', 'man', 'man', 'woman', 'woman', 'woman']}
df = pd.DataFrame.from_dict(data)
df.groupby('gender').median('convertedcomp')
Out [2]:
convertedcomp
gender
man 910
woman 42
按性别分组,并返回折算薪酬的中位数-
相关问题 更多 >
编程相关推荐