# Python | Numpy matrix.byteswap()

With the help of `Numpy matrix.byteswap()` method, we are able to swap the bytes place of the an element in the given matrix having one or more dimension. It would not work on matrix of type string or character.

Syntax : `matrix.byteswap()`

Return : Return the byteswapped matrix

Example #1 :
In this example we can see that with the help of `matrix.byteswap()` method we are able to swap the place of bytes of an element in a given matrix.

 `# import the important module in python ` `import` `numpy as np ` `          `  `# make a matrix with numpy ` `gfg ``=` `np.matrix(``'[1, 2, 3, 4]'``) ` `          `  `# applying matrix.byteswap() method ` `geeks ``=` `gfg.byteswap() ` `    `  `print``(geeks) `

Output:

```[[ 72057594037927936 144115188075855872 216172782113783808
288230376151711744]]
```

Example #2 :

 `# import the important module in python ` `import` `numpy as np ` `          `  `# make a matrix with numpy ` `gfg ``=` `np.matrix(``'[1, 2, 3; 4, 5, 6; 7, 8, 9]'``) ` `          `  `# applying matrix.byteswap() method ` `geeks ``=` `gfg.byteswap() ` `    `  `print``(geeks) `

Output:

```[[ 72057594037927936 144115188075855872 216172782113783808]
[288230376151711744 360287970189639680 432345564227567616]
[504403158265495552 576460752303423488 648518346341351424]]
```
My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.