Hướng dẫn dùng numpy sum python

numpy.sum[arr, axis, dtype, out] : This function returns the sum of array elements over the specified axis.

Parameters : 
arr : input array. 
axis : axis along which we want to calculate the sum value. Otherwise, it will consider arr to be flattened[works on all the axis]. axis = 0 means along the column and axis = 1 means working along the row. 
out : Different array in which we want to place the result. The array must have same dimensions as expected output. Default is None. 
initial : [scalar, optional] Starting value of the sum. 
Return : Sum of the array elements [a scalar value if axis is none] or array with sum values along the specified axis.

Code #1: 

Python3




# Python Program illustrating

# numpy.sum[] method

import numpy as np

      

# 1D array

arr

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
1
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
2
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
4
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
5
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
4
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
0
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
1

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
4
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
6

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
9# Python Program illustrating0 # Python Program illustrating1
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# Python Program illustrating3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 # Python Program illustrating5

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
9# Python Program illustrating0 # Python Program illustrating9
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# Python Program illustrating3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 # numpy.sum[] method3

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3 # numpy.sum[] method6
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# numpy.sum[] method8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 import1

import2import3

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# numpy.sum[] method8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 import8

 

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3 numpy as np0
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# numpy.sum[] method8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 import3numpy as np6 numpy as np7

import2import3

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# numpy.sum[] method8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 import3numpy as np6     6

Output:

Sum of arr :  36.2
Sum of arr[uint8] :  36
Sum of arr[float32] :  36.2

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  True

  Code #2: 

Python3




# Python Program illustrating

# numpy.sum[] method

import numpy as np

      

# 1D array2

arr

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 # 1D array5# 1D array6
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3# 1D array8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3arr0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3arr2
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3arr4arr5

import2

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
1arr8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
00
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
02
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
04
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
06
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
07

import2

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
1
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
10
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
4
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
14
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
16
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
19

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
4
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
6

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
9# Python Program illustrating0 # Python Program illustrating1
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# Python Program illustrating3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 # Python Program illustrating5

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
9# Python Program illustrating0 # Python Program illustrating9
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# Python Program illustrating3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 # numpy.sum[] method3

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3 # numpy.sum[] method6
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# numpy.sum[] method8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 import1

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
50import3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# numpy.sum[] method8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 import8

 

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3 numpy as np0
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# numpy.sum[] method8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 import3numpy as np6 numpy as np7

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
66import3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5# numpy.sum[] method8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 import3numpy as np6     6

Output:

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False

  Code #3: 

Python3




# Python Program illustrating

# numpy.sum[] method

      

import numpy as np

      

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
81

arr

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0 # 1D array5# 1D array6
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3# 1D array8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3arr0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3arr2
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3arr4arr5

import2

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
1arr8
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
00
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
02
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
04
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
06
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
07

import2

Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
1
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
10
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
4
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
14
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
16
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
19

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
4
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
6

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
9# Python Program illustrating0
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
27
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
29
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
30
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
32
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
29
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
35

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
9# Python Program illustrating0
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
27
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
16
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
30
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
32
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
16
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
35

 

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
49
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
50
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
51
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
52

Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
53import3
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
5
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
32
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
16
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
59
Sum of arr :  279
Sum of arr[uint8] :  23
Sum of arr[float32] :  279.0

Is np.sum[arr].dtype == np.uint :  False
Is np.sum[arr].dtype == np.float :  False
0
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
51
Sum of arr :  279
Sum of arr[axis = 0] :  [52 25 93 42 67]
Sum of arr[axis = 1] :  [120  75  84]

Sum of arr [keepdimension is True]: 
 [[120]
 [ 75]
 [ 84]]
35

Chủ Đề