Pandas的Series中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