My question is very simple, suppose I have an array like
array = np.array([1, 2, 3, 4])
and I would like to get an array like
[1, 0.5, 0.3333333, 0.25]
However, if you write something like
1/array
or
np.divide(1.0, array)
he will not work.
The only way I've found so far is to write something like:
print np.divide(np.ones_like(array)*1.0, array)
But I am absolutely sure that there is a better way to do this. Somebody knows?
source share