In [1]:
import numpy as np
In [2]:
a_2d = np.arange(12).reshape(3, 4)
print(a_2d)
In [3]:
a_2d[0, 0] = 100
print(a_2d)
In [4]:
a_2d[0] = 100
print(a_2d)
In [5]:
a_2d[np.ix_([False, True, True], [1, 3])] = 200
print(a_2d)
In [6]:
a_2d = np.arange(12).reshape(3, 4)
print(a_2d)
In [7]:
print(a_2d[::2, :3])
In [8]:
print(np.arange(6).reshape(2, 3) * 100)
In [9]:
a_2d[::2, :3] = np.arange(6).reshape(2, 3) * 100
print(a_2d)
In [10]:
a_2d = np.arange(12).reshape(3, 4)
print(a_2d)
In [11]:
print(a_2d[::2, :3])
In [12]:
print(np.arange(3) * 100)
In [13]:
a_2d[::2, :3] = np.arange(3) * 100
print(a_2d)
In [14]:
a_2d = np.arange(12).reshape(3, 4)
print(a_2d)
In [15]:
print(a_2d[::2, :3])
In [16]:
print(np.arange(2) * 100)
In [17]:
# a_2d[::2, :3] = np.arange(2) * 100
# ValueError: could not broadcast input array from shape (2) into shape (2,3)