pandas 列中子类别的中位数
Meadian of subcategories within a column in pandas
有没有办法计算列中子类别的中位数,
例如,
Education
primary
secondary
secondary
tertiary
primary
unknown
所以现在我想获得列中小学、中学、大学、未知类别的中位数
请帮助我 pandas.
中的代码
data screenshot
the Subcategories(count) whose median I want
I was able to resolve the issue after some time here's the code I used
df1=df['education'].value_counts()
df2=pd.Series(df['education'].value_counts()).values
sns.countplot(x='education',data = df)
plt.axhline(y=df2[0]/2, color='#e1812c', linestyle='-')
plt.axhline(y=df2[1]/2, color='#3274a1', linestyle='-')
plt.axhline(y=df2[2]/2, color='#3a923a', linestyle='-')
plt.axhline(y=df2[3]/2, color='#c03d3e', linestyle='-')
Plot result Image
有没有办法计算列中子类别的中位数,
例如,
Education
primary
secondary
secondary
tertiary
primary
unknown
所以现在我想获得列中小学、中学、大学、未知类别的中位数 请帮助我 pandas.
中的代码data screenshot
the Subcategories(count) whose median I want
I was able to resolve the issue after some time here's the code I used
df1=df['education'].value_counts()
df2=pd.Series(df['education'].value_counts()).values
sns.countplot(x='education',data = df)
plt.axhline(y=df2[0]/2, color='#e1812c', linestyle='-')
plt.axhline(y=df2[1]/2, color='#3274a1', linestyle='-')
plt.axhline(y=df2[2]/2, color='#3a923a', linestyle='-')
plt.axhline(y=df2[3]/2, color='#c03d3e', linestyle='-')
Plot result Image