unable to read a row in dataframe using the key Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of unable to read a row in dataframe using the key without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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']
We are here to answer your question about unable to read a row in dataframe using the key - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji