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