python - Faster string assignment using Numpy -
What can be used to assign fast string?
I like my string array
[['x1-y1', 'x1-y2' ...], ['x2-y2' 'x2- Y2 '...], .....]
so on
Then, each (i, j) = "x% dy% d"% (I, j) string
will this be done in Nampee?
If your array size is (m, m)
rx = np.utter (np. Ons (M,)), N. P. Linspace (1, M, M)) RI = NP. (N. P. Linspace (1, M, M), Np.ones ((m,)) s1 = np.chararray (M, m), itemsize = 1) s1 [:] = '' strarray = s1 + 'x' + np.array (rx, dtype = 'str') + '-' + 'y' + np.array (Ry, dtype = 'str')
output will be
chararray ([['X1.0-y1.0', 'x2. 0 'y1.0', 'x3.0-y1.0', 'x4.0-y1.0', 'x5.0-y1.0'], ['X1.0-y2.0', ' X2.0-y2.0 ',' x3.0-y2.0 ',' x4.0-y2.0 ',' x5.0-y2..0 '], [' x1.0-y3.0 '] , 'X2.0-y3.0', 'x3.0-y3.0', 'x4.0-y3.0', 'x5.0 -4.0'], ['x1.0-y4.0'] , 'X2.0-y4.0', 'x3.0-y4.0', 'x4.0-y 4.0', 'x5.0-y4.0'], ['x1.0-y5.0] ',' X2.0-y5.0 ',' x3.0-y5.0 ',' x4.0- Y5. 0 ',' x5.0-y5.0 ']], dtype =' | S68 ')
Comments
Post a Comment