Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
NumPy Array Shape
Next article icon
With the help ofNumpy matrix.reshape() method, we are able toreshape the shape of the given matrix. Remember all elements should be covered after reshaping the given matrix.
Syntax :matrix.reshape(shape)Return:new reshaped matrix
Example #1 :In the given example we are able to reshape the given matrix by usingmatrix.reshape() method.Python3 1=1
# import the important module in pythonimportnumpyasnp# make matrix with numpygfg=np.matrix('[64, 1; 12, 3]')# applying matrix.reshape() methodgeeks=gfg.reshape((1,4))print(geeks)
Output:
[[64  1 12  3]]
Example #2 :Python3 1=1
# import the important module in pythonimportnumpyasnp# make a matrix with numpygfg=np.matrix('[1, 2; 4, 5; 7, 8]')# applying matrix.reshape() methodgeeks=gfg.reshape((2,3))print(geeks)
Output:
[[1 2 4] [5 7 8]]

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp