正如列表一样,[:,:]代表一切从开始到结束的数据。不同是,第一个:代表第一维度,第二个:代表第二个维度。
p_opt = np.repeat(10, 3)
p_grid = np.tile(p_opt, (49, 1))
print(p_grid)
print(price_grid)
p_grid[:, 2]=price_grid #The third number in the second dimession is replaced by price_grid
print(p_grid)
p_opt = [[10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10] [10 10 10]]
price_grid = [ 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490]
赋值之后:
p_grid =
[[ 10 10 10] [ 10 10 20] [ 10 10 30] [ 10 10 40] [ 10 10 50] [ 10 10 60] [ 10 10 70] [ 10 10 80] [ 10 10 90] [ 10 10 100] [ 10 10 110] [ 10 10 120] [ 10 10 130] [ 10 10 140] [ 10 10 150] [ 10 10 160] [ 10 10 170] [ 10 10 180] [ 10 10 190] [ 10 10 200] [ 10 10 210] [ 10 10 220] [ 10 10 230] [ 10 10 240] [ 10 10 250] [ 10 10 260] [ 10 10 270] [ 10 10 280] [ 10 10 290] [ 10 10 300] [ 10 10 310] [ 10 10 320] [ 10 10 330] [ 10 10 340] [ 10 10 350] [ 10 10 360] [ 10 10 370] [ 10 10 380] [ 10 10 390] [ 10 10 400] [ 10 10 410] [ 10 10 420] [ 10 10 430] [ 10 10 440] [ 10 10 450] [ 10 10 460] [ 10 10 470] [ 10 10 480] [ 10 10 490]]