I have a Numpy Array with elements that are in single quotes and I want to convert the dtype to a float.
array =
[['20150101' '0.12']
['20150102' '0.42']
['20150103' '0.12']
['20150104' '0.46']
['20150105' '0.14']
['20150106' '0.1']
['20150107' '0.27']
['20150108' '0.03']
['20150109' '0.16']
['20150110' '0.29']
['20150111' '0.32']
['20150112' '0.16']]
I tried:
values = array.item().split(' ')
new_array = np.asarray(values, dtype='float')
but I get the ValueError: can only convert an array of size 1 to a Python scalar. I want the output to look like this: (No single quotes)
new_array =
[[20150101 0.12]
[20150102 0.42]
[20150103 0.12]
[20150104 0.46]
[20150105 0.14]
[20150106 0.10]
[20150107 0.27]
[20150108 0.03]
[20150109 0.16]
[20150110 0.29]
[20150111 0.32]
[20150112 0.16]]
Is there a numpy function that can allow me to remove the single quotes?
new_array = array.astype(float)?