1 import pandas 2 def price_3_to_7(a): 3 return 3<=a<=7 4 def time_3_to_8(b): 5 return 3<=b<=8 6 7 excel=pandas.read_excel('填充数据.xlsx',header=3,index_col='id') 8 excel.fillna(0,inplace=True) 9 10 #以下两个语句的功能都一样 11 #excel=excel.loc[excel['price'].apply(price_3_to_7)].loc[excel['time'].apply(time_3_to_8)] #进行两次筛选 12 excel=excel.loc[excel.price.apply(price_3_to_7)].loc[excel.time.apply(time_3_to_8)] #进行两次筛选 13 14 15 print(excel)