Python Pandas TimedeltaIndex.argmax
Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python包的奇妙生态系统。Pandas就是这些包中的一个,它使导入和分析数据变得更加容易。
Pandas TimedeltaIndex.argmax()函数返回TimedeltaIndex对象中沿某一轴的最大值的索引。该函数类似于numpy.ndarray.argmax。
语法: TimedeltaIndex.argmax(axis=None, *args, **kwargs)
参数 :
axis:无
返回:整数索引值
示例#1:使用TimedeltaIndex.argmax()函数,在给定的TimedeltaIndex对象中找到最大值的索引。
# importing pandas as pd
import pandas as pd
# Create the first TimedeltaIndex object
tidx = pd.TimedeltaIndex(start ='1 days 02:00:12.001124',
periods = 5, freq ='N', name ='Koala')
# Print the TimedeltaIndex object
print(tidx)
输出 :
现在我们将打印tidx对象中最大值的索引。
# return the index of maximum value.
tidx.argmax()
输出 :
正如我们在输出中看到的,TimedeltaIndex.argmax()函数有4个,表明tidx对象中的最大值出现在第4个索引。
示例#2:使用TimedeltaIndex.argmax()函数,在给定的TimedeltaIndex对象中找到最大值的索引。
# importing pandas as pd
import pandas as pd
# Create the TimedeltaIndex object
tidx = pd.TimedeltaIndex(data =['-1 days 2 min 3us 10ns',
'1 days 06:05:01.000030',
'-1 days + 23:59:59.999999'])
# Print the TimedeltaIndex object
print(tidx)
输出 :
现在我们将打印tidx对象中最大值的索引。
# return the index of maximum value.
tidx.argmax()
输出 :
正如我们在输出中看到的,TimedeltaIndex.argmax()函数有1,表明tidx对象中的最大值出现在第1个索引。