[Numpy-discussion] reshape/resize and array extension

Pierre Barthelemy barthpi at gmail.com
Thu Jun 7 09:16:42 EDT 2012


Hi everyone,

I am making a program to realize some "live" data analysis. I progressively
take the data, and write them in a file as a single column.
If i take 2D data, this would give:
data=
X Y Z
0 0 1
1 0 2
2 0 3
0 1 1
1 1 2
2 1 3
0 2 1
1 2 1
2 2 1

To plot these data, i need first to reshape the Z column as a 2D array:
z=data(:,2)
z.resize(len(x),len(y))

The issue is that in most of the case, are the data is built live, the last
line of the 2D array is almost never completed. To solve that issue i
complete it with 'nan'
 My code is then

z=append(z,zeros(len(x)*len(y)-len(z))*nan)
z.resize((len(y),len(x))

Is there a simpler/faster way to do that completing-reshaping step ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120607/f5162315/attachment.html>


More information about the NumPy-Discussion mailing list