![](/img/trans.png)
[英]How do I rank a list of features that I have picked out in the given data and rank the features?
[英]How do I sort and rank the data set
我有一個數據集,我需要對以下內容進行排序和排序:
d0 d1 d2 d3
configuration
theta0 1.0 2.0 2.0 1.0
theta1 3.0 1.0 3.0 3.0
theta2 2.0 3.0 4.0 2.0
theta3 4.0 4.0 1.0 4.0
雖然我的數據集是這樣的:
configuration d0 d1 d2 d3
theta0 0.89 0.82 0.87 0.86
theta1 0.73,0.84,0.85,0.78
theta2 0.81,0.79,0.71,0.85
theta3 0.64,0.65,0.99,0.61
在對各個列進行排序並賦予等級的情況下,
for dataset_name, dataset_values in copy_data.items():
sorted_list = dataset_values.sort_values(ascending=False)
count = 1
print(">>")
print(sorted_list)
for item in sorted_list:
copy_data[dataset_name][copy_data[dataset_name] == item] = count
count += 1
有更好的優化方法嗎?
你可以做
df.rank(ascending=False, method='first')
如果出現多次相同值,則將按列中的順序排列最高的第一個和第一個條目
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.