Do the rows or the columns count for dimensions of a Matrix in NumPy? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

Do the rows or the columns count for dimensions of a Matrix in NumPy?

The question may sound off topic and silly but I really want to know what exactly does signify the dimension in a numpy matrix - Rows or Columns? I have been following 3B1Bs series on Linear Algebra but I still strive harder when I comeback to learn numpy. :( The short example might ease things down. let there be a numpy array given as >>> x = np.array([[5, 2, 3], [2, 3, 2]]) >>> x.ndim [out] 2 This means (to my knowledge) that there are 2 dimension - obviously rows here. This confuses me because many YouTubers, books and especially 3b1b uses columns as dimension of the matrix! Thanks for the help!

25th Dec 2020, 1:53 PM
DarkRanger
DarkRanger - avatar
6 Antworten
+ 1
I've only just glanced over numpy....the dimensions means (sort of) now "deep" they are nested. c = np.array([[[1, 2, 3]]]) print(c.ndim) ...output = 3;
25th Dec 2020, 4:55 PM
rodwynnejones
rodwynnejones - avatar
+ 5
DarkRanger , this a link to a sololearn tutorial, that may cover your question: https://www.sololearn.com/learn/6671/?ref=app
25th Dec 2020, 3:49 PM
Lothar
Lothar - avatar
+ 1
Count of rows does not signify dimensions c = np.array([[1, 2, 3], [4, 5, 6], [7 ,8, 9]]) print(c.ndim)..... output = 2.
25th Dec 2020, 4:44 PM
rodwynnejones
rodwynnejones - avatar
0
>import numpy as np >b = np.array([1, 2, 3, 4]) Thanks Lothar, but as you can see, the question isnt addressed there either. My view is that the b should be 4 dimensional because there are 4 columns. I might be wrong but all Books use columns as a count of dimension of a Matrix.
25th Dec 2020, 4:11 PM
DarkRanger
DarkRanger - avatar
0
Thanks rodwynnejones,it makes sense that rows dont signify the dimension of matrix but I got even more confused as why it is 2 dimensions when there are 3 rows, and 3 columns. Does numpy use different aporoach or these arent fundamentally matrices?
25th Dec 2020, 4:50 PM
DarkRanger
DarkRanger - avatar
0
rodwynnejones thanks for the clarification. I think I skimmed over that part. Makes sense now!
26th Dec 2020, 2:55 AM
DarkRanger
DarkRanger - avatar