numpy-100 icon indicating copy to clipboard operation
numpy-100 copied to clipboard

100 numpy exercises (with solutions)

Results 48 numpy-100 issues
Sort by recently updated
recently updated
newest added

I run the code as the answer shows.But get ''' Exception: File `'`python.py'` not found. '''

I thought maybe using `.view()` may be faster. And it seems. ``` w, h = 256,256 l = np.random.randint(0,4,(h,w,3), dtype=np.uint8) l2 = np.zeros((h,w,4), dtype=np.uint8) l2[...,:3]=l[...,:3] l2[...,3] = l2[...,2] l3 =...

An example: ```py >>> a = np.random.randint(0, 10, (3, 3)) >>> a[:, [0, -1]] = 0 >>> a[[0, -1], :] = 0 >>> a array([[0, 0, 0], [0, 5, 0],...

Hey guys, I was going to start doing a bunch of exercises about numpy and to start I had to run the first cell. I appears to be an error...

> 82. Compute a matrix rank (★★★) > hint: np.linalg.svd > > \# Author: Stefan van der Walt > > Z = np.random.uniform(0,1,(10,10)) > U, S, V = np.linalg.svd(Z) #...

> 70. Consider the vector [1, 2, 3, 4, 5], how to build a new vector with 3 consecutive zeros interleaved between each value? (★★★) > hint: array[::4] > >...

As you suggested on #157, this PR gives an alternative solution for exercise 4

One could use simply `nbytes` to get an alternative solution to question 4. ``` >>> Z = np.zeros((10,10)) >>> print(f"{Z.nbytes} bytes") 800 bytes ```

`Q.83`: The `np.bincount` only counts **non-negative ints** according to its docs, which is not very useful in the dirty dataset. It can be optimized with `np.unique(data, return_counts=True)`, which returns the...