In [1]:
import numpy as np
In [2]:
a_3d = np.arange(24).reshape(2, 3, 4)
print(a_3d)
In [3]:
print(a_3d.shape)
In [4]:
a0, a1 = np.dsplit(a_3d, 2)
In [5]:
print(a0)
In [6]:
print(a0.shape)
In [7]:
print(a1)
In [8]:
print(a1.shape)
In [9]:
a0, a1 = np.dsplit(a_3d, [1])
In [10]:
print(a0)
In [11]:
print(a1)
In [12]:
a = np.arange(16).reshape(4, 4)
print(a)
In [13]:
# np.dsplit(a, 2)
# ValueError: dsplit only works on arrays of 3 or more dimensions