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.

Asked By: trickymaverick

||

Answers:

Try this:

import numpy as np
a = np.empty([2, 2], dtype = float)
print(a)

Output:.

[[0. 0.]
 [0. 0.]]
Answered By: Rishi Bansal
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.