且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

给定行和列索引,分配到NumPy数组的网格中

更新时间:2022-06-03 18:05:19

使用

Use np.ix_ to map that grid of elements and then assign -

x[np.ix_([0,1], [0,1])] = np.array([[1,0],[0,1]])