Been trying to search for this but somehow can't seem to find the right answer.
Given the following simple dataframe:
country continent population
0 UK Europe 111111
1 Spain Europe 222222
2 Malaysia Asia 333333
3 USA America 444444
How can I retrieve the country value if I have a condition WHERE an index value is given? For example, If I am given an index value of 2, I should return Malaysia.
Edit: Forget to mention that the input index value comes from a variable (think of it as a user select a particular row and the selected row provide an index value variable).
Thank you.
loc-df.loc[index,'country']