In [1]:
import numpy as np
In [2]:
a = np.arange(16).reshape(4, 4)
print(a)
In [3]:
a0, a1 = np.hsplit(a, 2)
In [4]:
print(a0)
In [5]:
print(a1)
In [6]:
a0, a1 = np.hsplit(a, [1])
In [7]:
print(a0)
In [8]:
print(a1)
In [9]:
a_1d = np.arange(6)
print(a_1d)
In [10]:
# np.split(a_1d, 2, 1)
# IndexError: tuple index out of range
In [11]:
a0, a1 = np.hsplit(a_1d, 2)
In [12]:
print(a0)
In [13]:
print(a1)