I am trying to save an array consisting of both floats and one column of strings, and I am getting some really weird results. This is what I have tried:
data = np.column_stack((f1, f2, f3, s1))
The first column (f1
) is long floats (Up to 10 digits, but I only need 2). I also need 2-3 digits on the second and third column, f2
and f3
respectively. The last column, s1
only consists of two different strings: 'FeI'
and 'FeII'
.
The problem is, that when I try to print data
I get something like this:
[['7352' '11.7' '-4.9' 'FeI']
...,
['5340' '22.8' '-8.2' 'FeII']]
While I would like to get something like this (I don't care if it save the floats as strings, as I can easily load them as floats afterwards):
[['7352.91' '11.78' '-4.92' 'FeI']
...,
['53407.66' '22.82' '-8.27' 'FeII']]
As you can see, the main problem is, that it 53407.66 turns into 5340 - a magnitude off!
Possible solution
To use np.array
instead and use the dtype
-option. However, I don't know how to store a column as strings. Any help?