
Can you clarify?
-----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Nils Wagner נשלח: ה 06-נובמבר-08 17:13 אל: numpy-discussion@scipy.org נושא: [Numpy-discussion] reshape
Hi all,
What can be done if the new shape is not compatible with the original shape ? The number of columns is fixed and should be 8.
One could split the original array C
C
array([[ 0.00000000e+00, 1.00000000e-01], [ 4.15000000e+01, 1.00000000e-01], [ 4.16000000e+01, 1.00000000e-01], [ 6.07500000e+01, 1.00000000e-01], [ 6.08500000e+01, 1.00000000e-01], [ 8.22550000e+01, 1.00000000e-01], [ 8.23550000e+01, 1.00000000e-01], [ 9.42550000e+01, 1.00000000e-01], [ 9.43550000e+01, 1.00000000e-01], [ 9.99100000e+01, 1.00000000e-01], [ 1.00010000e+02, 1.00000000e-01], [ 1.07660000e+02, 1.00000000e-01], [ 1.07760000e+02, 1.00000000e-01], [ 1.28000000e+02, 1.00000000e-01], [ 1.28100000e+02, 1.00000000e-01]])
shape(C)
(15, 2)
A = C[:8,:] A
array([[ 0. , 0.1 ], [ 41.5 , 0.1 ], [ 41.6 , 0.1 ], [ 60.75 , 0.1 ], [ 60.85 , 0.1 ], [ 82.255, 0.1 ], [ 82.355, 0.1 ], [ 94.255, 0.1 ]])
A = reshape(A,(2,8)) A
array([[ 0. , 0.1 , 41.5 , 0.1 , 41.6 , 0.1 , 60.75 , 0.1 ], [ 60.85 , 0.1 , 82.255, 0.1 , 82.355, 0.1 , 94.255, 0.1 ]])
B = C[8:,:] B
array([[ 9.43550000e+01, 1.00000000e-01], [ 9.99100000e+01, 1.00000000e-01], [ 1.00010000e+02, 1.00000000e-01], [ 1.07660000e+02, 1.00000000e-01], [ 1.07760000e+02, 1.00000000e-01], [ 1.28000000e+02, 1.00000000e-01], [ 1.28100000e+02, 1.00000000e-01]])
B = reshape(B,(2,7)) B
array([[ 9.43550000e+01, 1.00000000e-01, 9.99100000e+01, 1.00000000e-01, 1.00010000e+02, 1.00000000e-01, 1.07660000e+02], [ 1.00000000e-01, 1.07760000e+02, 1.00000000e-01, 1.28000000e+02, 1.00000000e-01, 1.28100000e+02, 1.00000000e-01]])
Nils _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion