Làm việc trên một dự án cung cấp cho chúng tôi triều đại miễn phí về những gì sẽ sử dụng. Vì vậy, tôi quyết định tôi sẽ học Python cho nó.
Để làm cho điều này ngắn gọn, tôi muốn tổng tất cả các yếu tố trong một "hàng" của một ma trận tôi đang đọc.
Đây là mảng 2D của tôi trông như thế nào sau khi tôi đọc trong bảng từ tệp văn bản của tôi.
Tôi muốn tổng hợp tất cả các phần tử của mỗi hàng không bao gồm chỉ mục 0 (số 4 chữ số). Và sau đó lưu trữ những khoản tiền đó trong một danh sách.
Tôi không chắc lỗi là gì, nhưng tôi nghĩ nó phải làm với chuyển đổi chuỗi/int. Vì bảng của tôi ở trong chuỗi, nhưng tôi chuyển đổi nó thành INTS để tổng hợp. Gỡ lỗi nó hiển thị kết quả chính xác, vì vậy tôi không chắc lỗi ở đâu.
Cải thiện bài viết
Lưu bài viết
ĐọcBàn luậnCải thiện bài viết
Lưu bài viết
Đọc This function returns the sum of array elements over the specified axis.
Bàn luận
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.
numpy.sum (mảng, trục, dtype, out): hàm này trả về tổng các phần tử mảng trên trục được chỉ định.
Python3
import
numpy as np
arr
____10 import
8import
9
[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3numpy as np
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3numpy as np
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3numpy as np
5[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3______8788number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
3number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
5number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
7number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
8 number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
9number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4import numpy
print ("Reading..")
txtfile = open("test1.txt", "r")
print(txtfile.readline())
txtfile.close()
r= numpy.genfromtxt('test1.txt',dtype=str,skiprows=1)
for x in range (0,len(r)):
print(r[x])
allTested = [0] * (len(r[0]) - 1)
num1s = [0] * (len(r[0]) - 1)
print("number of rows:", len(r))
print("number of cols:", len(r[0]))
print("num1s before:",num1s)
for x in range (0,len(r)):
for y in range(1,len(r[0])):
num1s[y-1] += int(r[x][y])
print("num1s after :",num1s)
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
0 import numpy
print ("Reading..")
txtfile = open("test1.txt", "r")
print(txtfile.readline())
txtfile.close()
r= numpy.genfromtxt('test1.txt',dtype=str,skiprows=1)
for x in range (0,len(r)):
print(r[x])
allTested = [0] * (len(r[0]) - 1)
num1s = [0] * (len(r[0]) - 1)
print("number of rows:", len(r))
print("number of cols:", len(r[0]))
print("num1s before:",num1s)
for x in range (0,len(r)):
for y in range(1,len(r[0])):
num1s[y-1] += int(r[x][y])
print("num1s after :",num1s)
3number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
7number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
8 import numpy
print ("Reading..")
txtfile = open("test1.txt", "r")
print(txtfile.readline())
txtfile.close()
r= numpy.genfromtxt('test1.txt',dtype=str,skiprows=1)
for x in range (0,len(r)):
print(r[x])
allTested = [0] * (len(r[0]) - 1)
num1s = [0] * (len(r[0]) - 1)
print("number of rows:", len(r))
print("number of cols:", len(r[0]))
print("num1s before:",num1s)
for x in range (0,len(r)):
for y in range(1,len(r[0])):
num1s[y-1] += int(r[x][y])
print("num1s after :",num1s)
7number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4import numpy
print ("Reading..")
txtfile = open("test1.txt", "r")
print(txtfile.readline())
txtfile.close()
r= numpy.genfromtxt('test1.txt',dtype=str,skiprows=1)
for x in range (0,len(r)):
print(r[x])
allTested = [0] * (len(r[0]) - 1)
num1s = [0] * (len(r[0]) - 1)
print("number of rows:", len(r))
print("number of cols:", len(r[0]))
print("num1s before:",num1s)
for x in range (0,len(r)):
for y in range(1,len(r[0])):
num1s[y-1] += int(r[x][y])
print("num1s after :",num1s)
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
0 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
1number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2 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
3number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4Sum 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
5____101010 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
8[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
40Sum 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
0number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4Sum 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
5[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
010 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
5Is
Các
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
& nbsp; Mã số 3: & NBSP;Code #2:
Python3
import
numpy as np
arr
____10 import
8import
9
[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3numpy as np
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3numpy as np
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3numpy as np
5[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3______8788Sum 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
9[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
1arr
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3arr
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3arr
5[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3arr
7[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3arr
9[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
00Sum 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
9[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
03[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
4[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
07[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
09[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
0[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
12number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
3number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
5number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
7number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
8 number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
9number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4import numpy
print ("Reading..")
txtfile = open("test1.txt", "r")
print(txtfile.readline())
txtfile.close()
r= numpy.genfromtxt('test1.txt',dtype=str,skiprows=1)
for x in range (0,len(r)):
print(r[x])
allTested = [0] * (len(r[0]) - 1)
num1s = [0] * (len(r[0]) - 1)
print("number of rows:", len(r))
print("number of cols:", len(r[0]))
print("num1s before:",num1s)
for x in range (0,len(r)):
for y in range(1,len(r[0])):
num1s[y-1] += int(r[x][y])
print("num1s after :",num1s)
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
0 import numpy
print ("Reading..")
txtfile = open("test1.txt", "r")
print(txtfile.readline())
txtfile.close()
r= numpy.genfromtxt('test1.txt',dtype=str,skiprows=1)
for x in range (0,len(r)):
print(r[x])
allTested = [0] * (len(r[0]) - 1)
num1s = [0] * (len(r[0]) - 1)
print("number of rows:", len(r))
print("number of cols:", len(r[0]))
print("num1s before:",num1s)
for x in range (0,len(r)):
for y in range(1,len(r[0])):
num1s[y-1] += int(r[x][y])
print("num1s after :",num1s)
3number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
7number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
8 import numpy
print ("Reading..")
txtfile = open("test1.txt", "r")
print(txtfile.readline())
txtfile.close()
r= numpy.genfromtxt('test1.txt',dtype=str,skiprows=1)
for x in range (0,len(r)):
print(r[x])
allTested = [0] * (len(r[0]) - 1)
num1s = [0] * (len(r[0]) - 1)
print("number of rows:", len(r))
print("number of cols:", len(r[0]))
print("num1s before:",num1s)
for x in range (0,len(r)):
for y in range(1,len(r[0])):
num1s[y-1] += int(r[x][y])
print("num1s after :",num1s)
7number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4import numpy
print ("Reading..")
txtfile = open("test1.txt", "r")
print(txtfile.readline())
txtfile.close()
r= numpy.genfromtxt('test1.txt',dtype=str,skiprows=1)
for x in range (0,len(r)):
print(r[x])
allTested = [0] * (len(r[0]) - 1)
num1s = [0] * (len(r[0]) - 1)
print("number of rows:", len(r))
print("number of cols:", len(r[0]))
print("num1s before:",num1s)
for x in range (0,len(r)):
for y in range(1,len(r[0])):
num1s[y-1] += int(r[x][y])
print("num1s after :",num1s)
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
0 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
1number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2 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
3number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4Sum 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
5____101010 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
8[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
40Sum 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
0number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4Sum 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
5[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
010 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
5Is
Các
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
& nbsp; Mã số 3: & NBSP;Code #3:
Python3
import
numpy as np
arr
____10 import
8import
9
[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3numpy as np
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3numpy as np
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3numpy as np
5[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3______8788Sum 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
9[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
1arr
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3arr
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3arr
5[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3arr
7[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3arr
9[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
00Sum 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
9[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
1[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
03[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
4[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
07[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
09[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
3number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
0[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
12number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
3number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
5number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
7number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
8 number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
11[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
0 number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
13number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
14__number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
7number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
8 number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
11[1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
0 [1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
09number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
14__number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
2number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
33number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
34 number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
35number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
36number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
37Sum 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
0number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
4number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
16____10 [1, 4, 4, 4, 4, 4, 5, 5, 3,.......,3] (Imagine it was all filled with the right sums)
09number of rows: 16
number of cols: 15
num1s before: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
num1s after : [3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 7, 9, 7]
43__Output:
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]]