[英]Ordering 3 1d numpy array to obtain a 2d numpy array
I have 3 numpy array containing x, y
and f(x,y) values
. 我有3个包含
x, y
和f(x,y) values
numpy数组。 They are ordered one with respect to the others but completely disordered in itself. 他们相对于其他人被命令一个人,但其本身完全无序。 Let's say, for sake of simplicity, that `f=x+y they are
假设,为简单起见,`f = x + y
x | y | f
1 | 2 | 3
5 | 1 | 6
....
And let's suppose that I know I have all the points to fill a grid. 并假设我知道我拥有填满网格的所有点。
I would like to obtain a mesh grid or a 2d python numpy array from it. 我想从中获取一个网格或2d python numpy数组。
In c I know how to do it, but I know in python "for"
cycles with element substitutions are avoidable and discouraged... 在c中,我知道该怎么做,但是我知道在python中
"for"
使用元素替换的"for"
循环是可以避免的,不鼓励使用...
Do you have any solution? 你有什么解决办法吗?
Thanks 谢谢
Take a look a the concatenate function. 看一下连接功能。
a = np.array([[x1, y1, f1]])
b = np.array([[x2, y2, f2]])
np.concatenate((a, b), axis=0)
http://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html http://docs.scipy.org/doc/numpy/reference/generation/numpy.concatenate.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.