首页 > 解决方案 > Pandas get cell value by row NUMBER (NOT row index) and column NAME

问题描述

data = [['tom', 10], ['nick', 15], ['juli', 14]] 
df = pd.DataFrame(data, columns = ['Name', 'Age'], index = [7,3,9])
display(df)
df.iat[0,0]

enter image description here

I'd like to return the Age in first row (basically something like df.iat[0,'Age']. Expected result = 10

Thanks for your help!

标签: pythonpandas

解决方案


df['Age'].iloc[0] works too, similar to what Chris had answered.


推荐阅读