简体   繁体   中英

How to get value from row for particular entity python

Fetch the age by specific name.

df = pd.DataFrame(data) 

在此处输入图像描述

I wants to get 'Age' for df['Name'] == 'Krish'

df.loc[df['Name']=='Krish','Age'].values[0]

If you wish to get answer in int/str/float convert it to list and then show the first value by [0]

df.loc[df['Name']=='Krish','Age'].tolist()[0]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM