squeeze numoy

Solutions on MaxInterview for squeeze numoy by the best coders in the world

showing results for - "squeeze numoy"
Paula
12 Aug 2017
1>>> x = np.array([[[0], [1], [2]]])
2>>> x.shape
3(1, 3, 1)
4>>> np.squeeze(x).shape
5(3,)
6>>> np.squeeze(x, axis=0).shape
7(3, 1)
8>>> np.squeeze(x, axis=1).shape
9Traceback (most recent call last):
10...
11ValueError: cannot select an axis to squeeze out which has size not equal to one
12>>> np.squeeze(x, axis=2).shape
13(1, 3)
14