← Back to NumPy Course | Chapter 5: Array Manipulation | Lesson 3 of 7

transpose() से Array पलटना

transpose() एक array को flip करता है ताकि इसकी rows columns बन जाएँ और columns rows बन जाएँ।

In this page:

  1. transpose()
Syntax
python
arr.transpose()
arr.T
np.transpose(arr, axes)

transpose()

एक 2-D array के लिए, transpose दो axes swap करता है; shortcut .T attribute है। Higher dimensions के लिए आप एक custom axis order pass कर सकते हैं। Result same data का एक view है।

Note: एक 1-D array .T से unchanged रहता है; पहले इसे एक 2-D array में reshape करें।

उदाहरण: transpose()

python
import numpy as np

m = np.array([[1, 2, 3], [4, 5, 6]])
print(m.shape)
print(m.T)
print(m.T.shape)

# Output:
# (2, 3)
# [[1 4]
#  [2 5]
#  [3 6]]
# (3, 2)
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह उम्मीद करना कि .T एक 1-D array को एक column में बदल देगा
  2. यह भूल जाना कि result एक view है
  3. 3-D arrays के लिए गलत axes order इस्तेमाल करना
चैप्टर सारांश
  • .T rows और columns swap करता है
  • np.transpose एक axes order accept करता है
  • एक view return करता है
  • 1-D arrays नहीं बदलते
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.