# Python | Numpy.expand_dims() method

With the help of `Numpy.expand_dims()` method, we can get the expanded dimensions of an array by using `Numpy.expand_dims()` method.

Syntax : `Numpy.expand_dims()`

Return : Return the expanded array.

Example #1 :
In this example we can see that using `Numpy.expand_dims()` method, we are able to get the expanded array using this method.

 `# import numpy ` `import` `numpy as np ` ` `  `# using Numpy.expand_dims() method ` `gfg ``=` `np.array([``1``, ``2``]) ` `print``(gfg.shape) ` ` `  `gfg ``=` `np.expand_dims(gfg, axis ``=` `0``) ` `print``(gfg.shape) `

Output :

(2, )
(1, 2)

Example #2 :

 `# import numpy ` `import` `numpy as np ` ` `  `# using Numpy.expand_dims() method ` `gfg ``=` `np.array([[``1``, ``2``], [``7``, ``8``]]) ` `print``(gfg.shape) ` ` `  `gfg ``=` `np.expand_dims(gfg, axis ``=` `0``) ` `print``(gfg.shape) `

Output :

(2, 2)
(1, 2, 2)

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

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.