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的值


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM