我有下面的numpy数组(包含字符串、字典和数字),并希望根据最后一列(数字)对该数组进行排序
X=[['few' {'age': 'young'} {'salary': 'low'} 0.8]
['few' {'salary': 'low'} {'age': 'young'} 0.3]
['few' {'age': 'young'} {'salary': 'medium'} 0]
...
['most' {'salary': 'medium'} {'education': 'upper'} 0.125]
['most' {'education': 'upper'} {'salary': 'high'} 0]
['most' {'salary': 'high'} {'education': 'upper'} 1]]
这可能是使用最后一列
X[-1]
作为排序key
的一种方法另一种选择是使用^{} ,其中
-1
表示最后一个条目/索引相关问题 更多 >
编程相关推荐