Use numpy array processing

fun_ndarray DEF (): 
A = [[1,2,7],
[-6, -2, -3],
[-4, -8, -55]
]
B = np.array (A)
B = NP. abs (b) # absolute value of the array
Print ( 'B [:, 0]')
Print (B [:, 0]) taking a first row of data #
Print ( 'B [:] [0]')
Print taking a first data line #: ([0] B [])
B_X B = [:, 0] + B [:, 2] # of the first and third columns are added elements
print (b_x)
results:

  b [:, 0] # first row
  [1. 6. 4]
  B [:] [0] # of the first row
  [127]
  [8959]

Guess you like

Origin www.cnblogs.com/shuangcao/p/11373820.html