How to create a numpy array with float values
Question:
I am wanting to create a numpy 2D array in which every element is a tuple of float values. I was trying to use np.range
and np.arange
but didn’t succeed. May I know of a concise way to do that? Thanks.
Answers:
Try this:
import numpy as np
a = np.empty([2, 2], dtype = float)
print(a)
Output:.
[[0. 0.]
[0. 0.]]
I am wanting to create a numpy 2D array in which every element is a tuple of float values. I was trying to use np.range
and np.arange
but didn’t succeed. May I know of a concise way to do that? Thanks.
Try this:
import numpy as np
a = np.empty([2, 2], dtype = float)
print(a)
Output:.
[[0. 0.]
[0. 0.]]