What does it mean that the shape of numpy's array is (100,)? Why is the second parameter missing?

Why the shape of

S1 is not (100) but (100,). What does the second parameter mean? Thank you

import numpy as np 
s1=np.array([])
for i in range(0,100):
    s1=np.append(s1,np.random.normal(0,1))
print(s1.shape)
====
(100,)
Feb.24,2022

shape () returns the length of each dimension when the data is used as a matrix.
for example:

arr1 = np.array([
    [1, 2],
    [1, 2]
])
arr1.shape -sharp (2, 2)

arr2 = np.array([
    [1, 2, 3],
    [1, 2, 3]
])
arr2.shape -sharp (2, 3)

arr3 = np.array([
    [
        [1, 2, 3, 4],
        [1, 2, 3, 4],
        [1, 2, 3, 4]
    ],
    [
        [1, 2, 3, 4],
        [1, 2, 3, 4],
        [1, 2, 3, 4]
    ]
])
arr3.shape -sharp (2, 3, 4)

the example you gave is an one-dimensional array, so the length of shape is only 1, and the outermost length is 100, so shape= (100,) .
reference:

Menu