(已解决)python如何将数组进行排序,如果两个值相等,则顺序并列。

(已解决)python如何将数组进行排序,如果两个值相等,则顺序并列。,第1张

import torch
import numpy as np
from scipy.stats import rankdata
a=torch.tensor([0, 2, 3, 2])
b=np.array([0, 2, 3, 2])
rankdata(a, method='dense')#tensor
rankdata(b, method='dense')#numpy都行

array([1, 2, 3, 2], dtype=int32)

其他用法如下:

参考:https://vimsky.com/zh-tw/examples/usage/python-scipy.stats.rankdata.html。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/801690.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-07
下一篇2022-05-07

发表评论

登录后才能评论

评论列表(0条)

    保存