Python: Operações com Matrizes do módulo Numpy
Operações com Matrizes
Usando o tipo array
#!/usr/bin/python
from numpy import *
arr =  array(
   [
       [1,2,3,4,5,6],
       [7,8,9,10,11,12]  
   ])
print("arr: \n", arr)
print()
print("dimensions: ", arr.ndim)
print("shape (rows,colums): ", arr.shape)
print("size: ", arr.size) 
arr2 = arr.flatten()
print("arr.flatten: ", arr2)
arr3 = arr.reshape(3,4)
print("arr.reshape: \n", arr3)
arr4 = arr.reshape(2,2,3)
print("arr.reshape: \n", arr4)
Resultado:
arr: [[ 1 2 3 4 5 6] [ 7 8 9 10 11 12]] dimensions: 2 shape (rows,colums): (2, 6) size: 12 arr.flatten: [ 1 2 3 4 5 6 7 8 9 10 11 12] arr.reshape: [[ 1 2 3 4] [ 5 6 7 8] [ 9 10 11 12]] arr.reshape: [[[ 1 2 3] [ 4 5 6]] [[ 7 8 9] [10 11 12]]]