python获取最大、最小值

1.获取数组极值,并返回索引

c = [-10,-5,0,5,3,10,15,-20,25]
 
print c.index(min(c)) # 返回最小值
print c.index(max(c)) # 返回最大值
2.对series求最值
file_path = 'D:/RecentReserch/TestData/alldayrequests2014.xlsx'
df = pd.read_excel(file_path,usecols=[1],encoding='utf-8-sig')
S=Series(df['Sessions'])
a=max(S.iloc[0:2]) #不包括索引2的值
posted @ 2019-08-01 10:11  Hellozhu  阅读(14676)  评论(0编辑  收藏  举报