筛选
def validate_age(age):
return 18 <= age <= 29
def validate_score(score,arg):
return arg <= score
for sheetname, sheetdatas in studentdatas.items():
print(sheetdatas.dtypes)
sheetdatas['Age']=sheetdatas['Age'].astype('int')
sheetdatas['Score']=sheetdatas['Score'].astype('int')
print(sheetdatas.dtypes)
studentdata = sheetdatas.loc[sheetdatas['Age'].apply(validate_age)].loc[sheetdatas['Score'].apply(validate_score,args=(90,))]
print(studentdata)
排序
for sheetname,sheetdatas in datas.items():
print(sheetdatas.head(8))
sheetdatas.sort_values(by=['Worthy','Price'],ascending=[True,False],inplace=True) # False 从大到小
print(sheetdatas.head(8))