index.tolist() 输出满足条件的索引内容
输出结果为list类型
例子:
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 17 11:08:01 2020
@author: jean2257
"""
import pandas as pd
daily = {'公司':['Ao','Bo','Bingo'],'排名':[3,2,1], '得分':[10, 15, 16]}
daily = pd.DataFrame(daily)
# 输出得分不低于15分的公司名称
daily.set_index('公司', inplace = True)
out = daily[daily['得分'] >= 15].index.tolist()
print(out)