https://www.udemy.com/course/ds_for_python/ I'm going to forget the command while I'm doing
import
import numpy as np
flatten()
flatten
array1=np.array([[1,2,3],[4,5,6],[7,8,9]])
array1.flatten()
array([1, 2, 3, 4, 5, 6, 7, 8, 9])
squeeze
squeeze
array1=np.array([[1,2,3]])
array1.shape
(1, 3)
squeeze
np.squeeze(array1)
(3,)
Reduce dimensions.
expand_dims
expand_dims
ndarray1=np.array([1,2,3])
ndarray1.shape
expand_axis=np.expand_dims(ndarray1, axis=-1)
expand_axis.shape
expand_axis
(3,)
(3, 1)
array([[1],
[2],
[3]])
On the contrary, increase the dimension. The place to increase changes with the argument of ʻaxis`.
Recommended Posts