python中idx是什么意思_Python pandas.DataFrame.idxmax函数方法的使用

DataFrame.idxmax(self, axis=0, skipna=True) [source]

返回在请求轴上第一次出现最大值的索引。不包括NA/null。

参数:axis : {0或'index',1或'columns'},默认0

行为0或'index',列为1或'columns'

skipna : boolean,默认为True

排除NA/null。如果整个行/列均为NA,则结果为NA。

返回值:Series

沿指定轴的最大值索引。

Raises:ValueError

如果行/列为空

Notes

此方法是的DataFrame版本ndarray.argmax。

例子

使用idxmax()函数来沿索引轴查找最大值的索引# importing pandas as pd

import pandas as pd

# Creating the dataframe

df = pd.DataFrame({"A":[4, 5, 2, 6],

"B":[11, 2, 5, 8],

"C":[1, 8, 66, 4]})

# Print the dataframe

df

输出:A B C

0 4 11 1

1 5 2 8

2 2 5 66

3 6 8 4

idxmax()沿索引轴应用# applying idxmax() function.

df.idxmax(axis = 0)

输出:A 3

B 0

C 2

dtype: int64

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值