Reputation: 2938
data = [['tom', 10], ['nick', 15], ['juli', 14]]
df = pd.DataFrame(data, columns = ['Name', 'Age'], index = [7,3,9])
display(df)
df.iat[0,0]
I'd like to return the Age in first row (basically something like df.iat[0,'Age']. Expected result = 10
Thanks for your help!
Upvotes: 5
Views: 7324
Reputation: 372
df['Age'].iloc[0]
works too, similar to what Chris had answered.
Upvotes: 7
Reputation: 29732
Use iloc
and Index.get_loc
:
df.iloc[0, df.columns.get_loc("Age")]
Output:
10
Upvotes: 4