Which Python module is suitable for data manipulation in a list? -


I have a sequence of X, Y and Z-Cordants, which I need to manipulate. In the list, such as {(x1, y1, z1), (x2, y2, z2), ...}.

In order to manipulate my data, I need extra, multiplication and logarithm.

I would like to study a module, which is powerful as Awk-language.

If you need to manipulate multiple arrays, then the numpy is the best option in the dragon

  & gt; & Gt; & Gt; Import samples & gt; & Gt; & Gt; Data = mmp.array ([(2, 4, 8), (3, 6, 5), (7, 5, 2)]))> gt; & Gt; & Gt; Data array ([[2, 4, 8], [3, 6, 5], [7, 5, 2]]) gt; & Gt; & Gt; Data.sum () # Products of all elements 42 & gt; & Gt; & Gt; Data.sum (axis = 1) The sum array of elements in # rows ([14, 14, 14])> gt; & Gt; & Gt; Data.sum (axis = 0) # sum of elements in columns ([12, 15, 15])> gt; & Gt; & Gt; Numpy.product (data, axis = 1) # product array of elements in rows ([64, 90, 70])> gt; & Gt; & Gt; Numpy.product (data, axis = 0) # elements of the elements in the column elements ([42, 120, 80]) & gt; & Gt; & Gt; Numpy.product # Products of all elements 403200  

or element wise operation with arrays

  & gt; & Gt; & Gt; X, y, z = map (numpy.array, [(2, 4, 8), (3, 6, 5), (7, 5, 2)]))> gt; & Gt; & Gt; X array ([2, 4, 8])> gt; & Gt; & Gt; Y array ([3, 6, 5]) & gt; & Gt; & Gt; Z array ([7, 5, 2]) & gt; & Gt; & Gt; X * y array ([6, 24, 40])> gt; & Gt; & Gt; X * y * z array ([42, 120, 80])> gt; & Gt; & Gt; X + y + z array ([12, 15, 15])  

Element-wise mathematical operations, e.g.

  & gt; & Gt; & Gt; Numpy.log (data) array ([[0.69314718, 1.38629436, 2.07944154], [1.0 9 861229, 1.79175947, 1.60 9 437 9]], [1.945 9 015, 1.60 9 4, 0.6 9314718]]))) Gt; & Gt; & Gt; Numpy.exp (x) array ([7.3890561, 54.59815003, 2980.95798704])  

Comments