我是Python的新手,不太清楚如何使用字典。我想要用另一个字典来对其中一个字典进行排序,就像下面所示。每个顶点特征都是一个列表。
vertex_features = ['Charge', 'Time', 'TimeDelta', 'TimeSinceLastPulse']
..........
..........
a = {feature : [] for feature in vertex_features }
我想对时间特征进行排序(并获取相应的费用、时间间隔等信息),我是通过以下方式实现的:
hit_order = np.argsort(features['Time'])
然而,当我尝试时
for feature in features:
features[feature] = features[feature][hit_order]
它报错了
TypeError: only integer scalar arrays can be converted to a scalar index
我也尝试过
for feature in features:
features[feature] = features[feature][for i in hit_order]
但是无法获得已排序的列表。我并不确定自己在这里排序时出了什么问题,非常感谢您的帮助。