python - Array to be reshaped
问题描述
I have a large array like this:
A =
[ array([[ 0. , 0. , 0. ],
[ 1. , 0. , 0. ],
[-1. , 0. , 0. ],
[-0.5 , 0.8660254 , 0. ],
[ 0.5 , -0.8660254 , 0. ],
[ 0. , 0. , 1.55 ],
[ 0. , 0. , -1.55 ]])
array([[ 2. , 0. , 0. ],
[-2. , 0. , 0. ],
[-1. , 1.73205081, 0. ],
[ 1. , -1.73205081, 0. ],
[ 0. , 0. , 3.1 ],
[ 0. , 0. , -3.1 ]])]
I would like to change it into one big matrix such as:
B = [ [0. 0. 0. ]
[1. 0. 0. ]
[-1. 0. 0. ]
[-0.5 0.8660254 0. ]
[0.5 -0.8660254 0. ]
[0. 0. 1.55 ]
[0. 0. -1.55 ]
[2. 0. 0. ]
[-2. 0. 0. ]
[-1. 1.73205081 0. ]
[1. -1.73205081 0. ]
[0. 0. 3.1 ]
[0. 0. -3.1 ]]
How can I do it? Can you please help me? Thanks for advance !!!
解决方案
定义A
为
A = [np.array([[ 0. , 0. , 0. ],
[ 1. , 0. , 0. ],
[-1. , 0. , 0. ],
[-0.5 , 0.8660254 , 0. ],
[ 0.5 , -0.8660254 , 0. ],
[ 0. , 0. , 1.55 ],
[ 0. , 0. , -1.55 ]]),
np.array([[ 2. , 0. , 0. ],
[-2. , 0. , 0. ],
[-1. , 1.73205081, 0. ],
[ 1. , -1.73205081, 0. ],
[ 0. , 0. , 3.1 ],
[ 0. , 0. , -3.1 ]])]
只需使用np.concatenate(A)
,它将加入数组序列:
np.concatenate(A)
array([[ 0. , 0. , 0. ],
[ 1. , 0. , 0. ],
[-1. , 0. , 0. ],
[-0.5 , 0.8660254 , 0. ],
[ 0.5 , -0.8660254 , 0. ],
[ 0. , 0. , 1.55 ],
[ 0. , 0. , -1.55 ],
[ 2. , 0. , 0. ],
[-2. , 0. , 0. ],
[-1. , 1.73205081, 0. ],
[ 1. , -1.73205081, 0. ],
[ 0. , 0. , 3.1 ],
[ 0. , 0. , -3.1 ]])
推荐阅读
- azure-ad-b2c - 无法翻译“验证码已发送,请复制到下方输入框。” 信息
- scala - Scala Future flatMap 实现(链接)
- c# - 如何使组合框选择更改在 C# 中进行计算
- python - 如果字符串由特定字母组成,则根据该过滤数据框
- http-headers - 内容安全策略阻止白名单域
- python-3.x - 尝试在 Python3 中使用中序遍历来验证二叉搜索树。我的方法有什么问题?
- python - 平滑地上下移动火球 Pygame
- python - 带有 Azure AD SSO 的 Snowflake python 连接器
- postgresql - 如何将 IAM 服务帐号连接到 Cloud SQL 实例
- python - 张量与向量列表的快速元素乘法