I'm new to Python and stackoverflow. So please forgive any shortcomings in my posting. I want to calculate the row average of a specific row(e.g. Bahrain) and I'm having problem achieving it. I used df.loc but It's returning a key error with the name of the country as it doesn't recognize the name. My dataframe look like something like this:
Country 1990 1995 2000 2005 2010 2015 0 Bahrain 5 4 3 2 1 5 1 Maldives 10 9 8 7 6 5 2 Germany 7 4 3 2 1 7 . .... .. .. .. .. .. .. . .... .. .. .. .. .. .. . .... .. .. .. .. .. .. I wrote this and I get an error.I got a key error with the name of row.
mean=df.loc['Bahrain'].mean(axis=1) [The error](

type here
Источник: https://stackoverflow.com/questions/780 ... -the-row-v