It is three dimensional array im creating but it shows it 2 dimensional array. Anybody explain? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

It is three dimensional array im creating but it shows it 2 dimensional array. Anybody explain?

import numpy as np my_arr = np.array([[1,2,3,4,5],[6,7,8,9,10],[12,32,34,56,321]]) #crearing a array with numpy print(my_arr) #creating a dimension of array print(my_arr.ndim)

25th Apr 2022, 1:28 AM
Amala Yakin
3 Respostas
+ 1
Youā€˜re missing another [ ] arround the arra (it needs three levels for beinf 3d, as far as i know).
25th Apr 2022, 4:20 AM
Dr. Steffen Lesle
+ 2
# Hi! You can take a look at this one: import numpy as np my432 = np.array([ [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]], [[13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]] ]) print(my432) print(f"\n{my432.ndim = }")
25th Apr 2022, 5:05 AM
Per Bratthammar
Per Bratthammar - avatar
+ 1
Thank you guys
25th Apr 2022, 7:16 AM
Amala Yakin