I have the following arrays:
a = ['(0.0 | 0.0 | 0.0)', '(0.0 | 0.0 | 0.1)'] # strings
b = [0.0, 0.1] # floats
c = [0.0, 0.2] # floats
d = [0.0, 0.3] # floats
e = [0.0, 0.4] # floats
My goal is to create a final 2d array, such that the datatypes are preserved, with numpy:
final = [a, b, c, d, e] -> [ ['(0.0 | 0.0 | 0.0)', ...] , [0.0, 0.1], ... ]
When I tried to do this with
np.array([a, b, c, d, e])
what happens is that the floats are converted to strings. Naturally, I went to look at the dtype documentation from numpy dtype doc and tried to create my own personal dtype through
dt = np.dtype([('f1', np.str), ('f2', np.float), ('f3', np.float), ('f4', np.float), ('f5', np.float)])
final = np.array([a, b, c, d, e], dtype=dt)
However it's trying to convert the string array into floats:
ValueError: could not convert string to float: '(0.0 | 0.0 | 0.0)'
Does anyone know what I'm doing wrong? This should be possible...