题目:
找到下面年龄最大的人,并输出。
person = {“li”:18,“wang”:50,“zhang”:20,“sun”:22}
代码:
import pandas as pd
person = {"li":18,"wang":50,"zhang":20,"sun":22}
person_df = pd.Series(person).sort_values(ascending=False)
eldest_name,eldest_age = person_df.index[0],person_df.iloc[0]
print(eldest_name,eldest_age)
运行结果:
wang 50
[Finished in 6.8s]