This question already has an answer here:
I have a numpy.ndarray
a = [['-0.99' '' '0.56' ..., '0.56' '-2.02' '-0.96']]
how to convert it to int?
output :
a = [[-0.99 0.0 0.56 ..., 0.56 -2.02 -0.96]]
I want 0.0 in place of blank ''
This question already has an answer here: I have a numpy.ndarray
how to convert it to int? output :
I want 0.0 in place of blank '' |
||||
marked as duplicate by Bakuriu, Maxime Lorant, Toto, Frédéric Hamidi, robert Jan 30 '14 at 12:01This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. |
||||
Result is:
Your values are floats, not integers. It is not clear if you want a list of lists or a numpy array as your end result. You can easily get a list of lists like this:
Result:
|
|||
|
That is a pure python solution and it produces a With simple python operations, you can map inner list with float. That will convert all string elements to float and assign it as the zero indexed item of your list.
Update: Try the following
It enumerates the objects in the list and try to parse them to |
|||||||||||||
|
a.astye(float)
. Bear in mind, that a must be a numpy array. – Christian Jan 30 '14 at 9:04astype
and that is what you're looking for – Vincent Jan 30 '14 at 9:07array
s. Not sure what you mean by a NumPy list ... – ssm Jan 30 '14 at 9:08