我想按名称从表中获取价值。我的桌子是
school = [['Jason',100],
['Alice',87.89],
['Mary',68]]
school = pd.DataFrame(school, columns=['Name','Grade'],dtype=float)
我想返回'Jason'
的成绩。我试过school ['Jason']返回100,但它不起作用。
如何通过从表中调用名称来返回值?对于任何帮助和提示将不胜感激。
答案 0 :(得分:0)
这将起作用:
grades_of_jason = school[school['Name'] == Jason]['Grade'] # filter for rows with name = json, then get grade of those rows
print(list(grades_of_jason)[0]) # get first item of this series
100