[英]How to find the biggest value in the pandas dataset
试试
df.index[df.AIDS.eq(df.drop('Total',1).max(1))]
Have a look at pandas max function ( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.max.html )看看熊猫最大函数( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.max.html )
Here you could get the max for each row, as is:在这里,您可以获得每行的最大值,如下所示:
most_frequent_disease = df.drop(columns=['Total', 'Other']).max(axis=1)
Then you can create a condition to check wether AIDS is the most frequent disease, and apply it to your dataframe:然后您可以创建一个条件来检查 AIDS 是否是最常见的疾病,并将其应用于您的数据框:
is_aids_most_frequent_disease = df.loc[:, 'A'].eq(most_frequent_disease)
df[is_aids_most_frequent_disease]
You could get the country name by using the .index
at the end of the expression too.您也可以通过在表达式末尾使用
.index
来获取国家/地区名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.