rowsums=df[['salary','new']].apply(np.sum,axis=1) res=df.iloc[np.where(rowsums>60000)[0][-3:],:]
将salary列和new列求和,取出大于60000的最后3行,但第二句怎么理解呀?特别是“[0][-3:],:”这玩意儿?
rowsums=df[['salary','new']].apply(np.sum,axis=1) res=df.iloc[np.where(rowsums>60000)[0][-3:],:]
将salary列和new列求和,取出大于60000的最后3行,但第二句怎么理解呀?特别是“[0][-3:],:”这玩意儿?
np.where(rowsums>60000)[0][-3:]是行索引
[-3:]取前面结果的最后3行