Pandas シリーズの argmax() と idxmax() の違い

argmax() は最大値の int 位置を返します。つまり、添字
idxmax() は最大値のインデックス値を返します。

コード例:

# Pandas的Series中argmax()和idxmax()的区别
series_b=[6,7,8,9]
series_b=pd.Series(series_b,index=['a','b','c','d'])

print(series_b)
print('---------------')
print('argmax:',series_b.argmax())#返回最大值的int位置,也就是下标
print('idxmax:',series_b.idxmax())#返回最大值的索引值

出力結果:

a    6
b    7
c    8
d    9
dtype: int64
-------------
argmax: 3
idxmax: d

Process finished with exit code 0

おすすめ

転載: blog.csdn.net/m0_37690430/article/details/127185238