python - Numpy 中的归约和追加

标签 python numpy append reduce

有没有办法将reduce与numpy的append一起使用?我想像这样将 3 个数组 append 在一起:

a = np.array([1,2,3])  
b = np.array([11,12,13])  
c = np.array([21,22,23])
#below is my real code - the above is just for this example)
np.append.reduce((a,b,c))

但看起来reduce 没有用append 实现。感谢您的任何建议。

输出应该是:

array([ 1,  2,  3, 11, 12, 13, 21, 22, 23])

最佳答案

np.r_[] 会干净地完成此操作...

a = np.array([1,2,3])  
b = np.array([11,12,13])  
c = np.array([21,22,23])
#below is my real code - the above is just for this example)
np.r_[a,b,c]

关于python - Numpy 中的归约和追加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56877033/

相关文章:

python - 点积稀疏矩阵

python - 如何将 3 个列表转换为 1 个 3D Numpy 数组

python - 2 的补码十六进制值的有符号等价物

python - opencv python 将不同 channel 的图像合并为一个

javascript - 添加和删​​除 jquery li 元素

javascript - 将每个 div 的内容 append 到 textarea

VBA:将具有值的字段添加到记录集

python - coverage.py中的声明是什么?

python - OpenStack Python Novaclient 不需要认证

python - 获取 "new-line character seen in unquoted field"读取 csv 文件时出错