NumPy | Python Methods and Functions

With the

method we can replace the axes with a matrix using the same method. **matrix.swapaxes()**

Syntax:`matrix.swapaxes ()`

Return:Return matrix having interchanged axes

** Example # 1: **

In this example we can swap the matrix axes using ` matrix.swapaxes () `

.

` `

` ` ` # import an important module into python `

` import `

` numpy as np `

` # make a matrix with NumPy `

` gfg `

` = `

` np.matrix (`

` `[4, 1; 12, 3] ``

`) `

` `

` # applying the matrix.swapaxes () method `

` geek `

` = `

` gfg.swapaxes (`

` 0 `

` , `

` 1 `

`) `

` `

` ` ` print `

` (geek) `

` `

** Exit :**

[[4 12] [1 3]]

** Example # 2: **

` ` |

** Exit:**

[[4 1 9] [12 3 1] [4 5 6]]

Pandas for Everyone: Python Data Analysis (Addison-Wesley Data & Analytics Series), 1st Edition. Pandas for Everyone brings together the practical knowledge and insights you need to solve real-worl...

05/09/2021

This is the first book on synthetic data for deep learning, and its extensive coverage could make this book the standard benchmark for synthetic data for years to come. The book can also serve as an i...

28/08/2021

A Gentle Introduction to Numerical Simulations with Python 3.6. Computing, in the sense of doing mathematical calculations, is a skill that mankind has developed over thousands of years. Programmin...

23/09/2020

While there is no arguing about the staying power of the cloud model and the benefits it can bring to any organization or government, mainstream adoption depends on several key variables falling into ...

10/07/2020

X
# Submit new EBook