numpy advanced

Jimmy (xiaoke) Shen
1 min readMar 24, 2020

--

Numpy dimensions

Broadcasting

reference: https://www.youtube.com/watch?v=EEUXKG97YRw

argmin argmax unravel_index

>>> a =  np.random.randn(2,3)
>>> a
array([[ 1.38895025, -1.70065705, -0.50334658],
[-1.69245193, 0.30436527, 0.54569745]])
>>> idx = np.argmin(a)
>>> np.unravel_index(idx, a.shape)
(0, 1)
>>> a[np.unravel_index(idx, a.shape)]
-1.700657050456571

How numpy array is saved in memory

flattening array

Reference

http://vanderplas.com/speaking.html

--

--

No responses yet