比较数据框列的值

时间:2019-09-02 10:56:19

标签: pandas

我想检查数据帧的最后一个值是否等于某个值。 像

Name     class     year 

abc      17        2018
cdf      23        2016
ded      39        2019

代码

if df['year'].loc[:-1] == 2019:
    print ('yes')  

The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

0 个答案:

没有答案