python - What does np.cumsum(0) do? -
a = np.array([[1,2,3], [4,5,6]]) np.cumsum(a) i know output of above array([ 1, 3, 6, 10, 15, 21]) displays cumulative sums of array a.
however, have trouble understand following. cumsum(0) do?
np.random.randn(365).cumsum(0)
this isn't numpy.cumsum(0)
here, 0 axis parameter of cumsum method of array object defined np.random.randn(365). can omitted in case (default none flatten array, array flat here)
np.cumsum function taking array first argument, whereas in second example cumsum method of array (both same computation, first 1 having no axis, flattens in process)
Comments
Post a Comment