How to combine np string array with float array python -


i combine array full of floats array full of strings. there way this?

(i having trouble rounding floats, insert changing them scientific notation; unable reproduce small example)

a=np.array([[1/3,257/35],[3,4],[5,6]],dtype=float) b=np.array([7,8,9],dtype=float) c=np.insert(a,a.shape[1],b,axis=1) print(np.arround(b,decimals=2)) d=np.array(['name1','name2','name3']) 

how append d onto end of c in same way appended b onto (insert d last column of c)?

i suspect there type issue between having strings , floats in same array. answer questions if there way change float (or maybe scientific number, numbers displayed '5.02512563e-02') string 4 digits (.0502).

i believe concatenate not work, because array dimensions (3,3) , (,3). d 1-d array, d.t no different d. also, when plug in "valueerror: input arrays must have same number of dimensions."

i don't care accuracy loss due appending, last step before print.

try making d numpy array first, transposing , concatenating c:

d=np.array([['name1','name2','name3']]) np.concatenate((c, d.t), axis=1) 

see documentation concatenate explanation , examples: http://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -