[Numpy-discussion] structured array from ordinary array
Sun Dec 13 20:24:17 CST 2009
On Dec 13, 2009, at 8:54 PM, Ernest Adrogué wrote:
> How does one generate a structured array from a normal
> I use the 'view' method, but this way I get a superfluous
> dimension that I do not want. Example:
> In : a = np.array([[1,2,3],[1,2,3],[1,2,4]],int)
> In : struct = np.dtype([('a',int),('b',int),('c',int)])
> In : a.view(struct)
> I'd like the last array to have shape (3,).
> What am I doing wrong??
Put a .squeeze() after your view()
More information about the NumPy-Discussion