SoFunction
Updated on 2024-12-16

numpy's method for adding elements to an empty two-dimensional array

Straight to the code.

x = (shape=[0, 4], int)
x = (x, [[1,2,3,4]], axis = 0)
x = (x, [[1,2,3,4]], axis = 0)

This adds two rows and four columns of data. Note that append is two layers of brackets, this is very important, if you miss it is not a two-dimensional array, with axis will be reported when the dimension does not match.

The above method of adding elements to an empty two-dimensional array by numpy is all that I have shared with you, and I hope that it will give you a reference, and I hope that you will support me more.