我正在尝试使用numpy数组来完成以下操作:
x = [(0.1, 1.), (0.1, 2.), (0.1, 3.), (0.1, 4.), (0.1, 5.)]
normal_result = zip(*x)
这应该会给出一个结果:
normal_result = [(0.1, 0.1, 0.1, 0.1, 0.1), (1., 2., 3., 4., 5.)]
但如果输入向量是一个NumPy数组:
y = np.array(x)
numpy_result = zip(*y)
print type(numpy_result)
它(预期地)返回一个:
<type 'list'>
问题在于我需要在此之后将结果转换回numpy数组。我想知道是否有一种高效的numpy函数可以避免来回转换?