简体   繁体   English

Append 值到 n 维 np 数组

[英]Append value to n dimensional np array

I have an array of dimension [755,25] where 755 is the number of rows and 25 is the number of values in each row I want to append a constant value say '6' to each row such that the resultant array has dimensions as [755,512]我有一个维度为 [755,25] 的数组,其中 755 是行数,25 是每行中的值的数量我想要 append 一个常数值,对每一行说“6”,这样结果数组的维度为[755,512]

Please can anybody help with this?请问有人可以帮忙吗?

import numpy as np

a = np.zeros((755, 25))
b = np.zeros((755, 512))
b[:, :25] = a
b[:, 25:] = 6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM