0
data.groupby('Income group')['Poorest (Wealth quintile)'].mean()
Income group
High income (H)             30.400000
Low income (L)               3.000000
Lower middle income (LM)     6.090909
Upper middle income (UM)    36.440000
Name: Poorest (Wealth quintile), dtype: float64

This code gives me the following output, but I only want Upper middle in the output. How do I do this?

Andrej Kesely
  • 168,389
  • 15
  • 48
  • 91
  • Follow the suggestions in this thread to improve your question: https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – navneethc Aug 24 '23 at 13:18
  • would appriciate for an upvote if it solves your problem my friend! welcome to StackOverflow – dotheM Aug 24 '23 at 15:05
  • Please provide enough code so others can better understand or reproduce the problem. – Community Aug 25 '23 at 20:51

1 Answers1

0

You simply just do this:

result = data.groupby('Income group')['Poorest (Wealth quintile)'].mean()
print(result.loc['Upper middle income (UM)'])
dotheM
  • 140
  • 6