With the matrix.squeeze()
method we can compress the size of the matrix using the same method. But remember one thing: we are using this method on a matrix of Nx1 size, which is returned as a 1xN matrix.
Syntax:
matrix.squeeze ()
Return: Return a squeezed matrix
Example # 1:
In this example, we can compress the size of the given matrix using matrix.squeeze ()
.
# import important module in python
import
numpy as np
# make a matrix with NumPy
gfg
=
np.matrix (
`[[4], [12]]`
)
# using the matrix.squeeze () method
gfg.squeeze ()
print
(gfg)
Output:
[[4 12]]
Example # 2:

Exit:
[[4 1 9] [12 3 1] [4 5 6]]
Pandas 1.x Cookbook: Practical recipes for scientific computing, time series analysis, and exploratory data analysis using Python, 2nd Edition....
05/09/2021
This book introduces machine learning methods in finance. It features a unified treatment of machine learn...
12/08/2021
In the last decade, we have seen the impact of exponential advances in technology on the way we work, shop, communicate, and think. At the heart of this change is our ability to collect and gain insig...
10/07/2020
Coding for Kids: Python  Learn to Code with 50 Awesome Games and Activities. Learning to code isn't as difficult as it sounds, you just have to get started! Coding for Kids: Python gets kids start...
31/08/2021