我有一个(4,6,3)维DataArray。我想更新特定的行和列。
假设我想将n1 [18,4,81]的第一行更新为[0,0,0]并将n4 [15,20,31,91,27,39]的最后一列更新为[1 ,1,1,1,1,1]。请说明怎么样?
tmp=xr.DataArray(np.random.randint(99,size=(4,6,3)), coords={'sample':['n1','n2','n3','n4'],'delta':['dx','dy','dz']}, dims=('sample','y','delta'))
<xarray.DataArray (sample: 4, y: 6, delta: 3)>
array([[[18, 4, 81],
[74, 38, 78],
[66, 82, 34],
[47, 60, 8],
[21, 44, 56],
[72, 16, 72]],
[[58, 57, 80],
[56, 17, 17],
[61, 83, 87],
[ 3, 53, 48],
[46, 49, 20],
[97, 96, 3]],
[[ 8, 73, 79],
[20, 89, 16],
[70, 39, 60],
[32, 52, 49],
[41, 79, 19],
[91, 25, 40]],
[[39, 11, 15],
[78, 55, 20],
[78, 43, 31],
[92, 50, 91],
[44, 61, 27],
[79, 16, 39]]])
Coordinates:
* sample (sample) |S2 'n1' 'n2' 'n3' 'n4'
* delta (delta) |S2 'dx' 'dy' 'dz'
Dimensions without coordinates: y
答案 0 :(得分:1)
$secret_key = 'mysecretkey';
$remote_url = 'http://siteb.com/api/';
$action = 'GET';
$account = 'john.doe@email.com';
$point_type = 'my_custom_type';
$host = get_bloginfo( 'url' );
$token = md5( $host . $action . $secret_key );
$request = array(
'method' => 'POST',
'body' => array(
'action' => $action,
'account' => $account,
'type' => $point_type,
'token' => $token,
'host' => $host
)
);
$response = wp_remote_post( $remote_url, $request );
答案 1 :(得分:0)
tmp[0][0] = [0,0,0] # updates first row to [0,0,0]
for x in range(len(tmp[3])): # update last column
tmp[3][x][2] = 1