unable to read a row in dataframe using the key

thanks in advance for your help.

my dataframe looks as follows

I can read the row using the following command

Energy.iloc['Afghanistan']

but Energy['Afghanistan'] returns a “key error”

Can someone help me understand why this is.

Afghanistan is in the index.

Answer

Try using loc instead:

Energy.loc['Afghanistan']