gpt4 book ai didi

python - Numpy 中的归约和追加

转载 作者:太空宇宙 更新时间:2023-11-03 20:40:50 25 4
gpt4 key购买 nike

有没有办法将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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com