python3中rank函式的用法

2022-09-27 06:24:11 字數 578 閱讀 3203

網上存在這麼乙個例子

obj = pd.series

obj.rank()

輸出為:

0 6.5

1 1.0

2 6.5

3 4.5

4 3.0

5 2.0

6 4.5

dtype: float64

之前一直沒弄懂是啥意思 這裡解釋下

rank 表示在這個數在原來的向量中排第幾名,有相同的數,按最小排序,取平均(預設)。這裡解釋下

0 6.5 這裡的0就是值得obj中的第乙個數 也就是7 應該排名第七 但是第六名和第七名都一樣 取平均值

1 1.0 這裡的1指www.cppcns.com的是objpjnxrwneoj中的第二個數 也就是-5 排名第一名 (按最小值排序)

2 6.5 以此類推

3 4.5

4 3.0

5 2.0

6 4.5

dtype: float64

本文標題: python3中rank函式的用法

本文位址: /jiaoben/python/289205.html

關於Python中rank 函式的理解

rank也就是所說的 排名 是指對陣列從1到有效資料點總數分配名次的操作。預設情況下,rank通過將平均排名分配到每個組來打破平級關係 import pandas as pd obj pd.series 7,5,7,4,2,0,4 obj執行結果 0 71 5 2 73 4 4 25 0 6 4dt...

python3中的format函式

原文出處 format函式常與print 函式結合使用,具備很強的格式化輸出能力。通過變數,逗號隔開 print 今天 format 我 攔路雨 action 在寫部落格 通過關鍵字使用字典傳入,在字典前加入 grade print 比較無聊,在 format grade 字典前加上 通過位置 pr...

python3 中的 eval 函式

from python eval的妙用和濫用 python eval python eval 函式妙用 python 中 eval 帶來的潛在風險 python之 eval 函式危險性 eval 函式十分強大,官方文件解釋是 將字串 string 物件 轉化為有效的表示式參與求值運算返回計算結果 語...