[Numpy-discussion] Difference between shape=() and shape=(1,)

Pauli Virtanen pav@iki...
Tue Jul 13 12:36:44 CDT 2010


ti, 2010-07-13 kello 10:06 -0700, Keith Goodman kirjoitti:
> No need to use where. You can just do a[np.isnan(a)] = 0. But you do
> have to watch out for 0d arrays, can't index into those.

You can, but the index must be appropriate:

>>> x = np.array(4)
>>> x[()] = 3
>>> x
array(3)




More information about the NumPy-Discussion mailing list