如何随机化键值对列表的顺序?

how can I randomize the order of a list of keys and value pairs?

我有以下 12 项配对 ["key", values] 的列表。 例如第一项是:["SN00003025", 0.1]

["SN00003025", 0.1], ["SN00013002", 30000.0], ["SN00037509", 23.7],
["SN00126162", 13560.0], ["SN00155812", 7.8], ["SN00232427", 3000.0], 
["SN00316328", 12.0], ["SN00319987", 5456.0], ["SN00339436", 5600.0],
["SN00399476", 12500.0], ["SN00399477", 32.0], ["SN00399478", 1100.0]

如何将此列表的项目顺序更改为随机?

您可能正在寻找类似 numpy.random.permutation 的内容:https://numpy.org/doc/stable/reference/random/generated/numpy.random.permutation.html

import numpy as np
lst = # ... Your list
permuted = np.random.permutation(lst)
import random

random.shuffle(my_list)