a.flatten(‘F’) 按列降维
a.flatten(‘A’) 按行降维 (默认)
a=np.array([[1,2],
[3,4],
[5,6]])
>>> a.flatten('F') #按列降维
array([1, 3, 5, 2, 4, 6])
>>> a.flatten('A') #按行降维
array([1, 2, 3, 4, 5, 6])
本文详细介绍了Python中使用numpy库的flatten方法如何将二维数组按列(F)和行(A,默认)进行降维操作。
a.flatten(‘F’) 按列降维
a.flatten(‘A’) 按行降维 (默认)
a=np.array([[1,2],
[3,4],
[5,6]])
>>> a.flatten('F') #按列降维
array([1, 3, 5, 2, 4, 6])
>>> a.flatten('A') #按行降维
array([1, 2, 3, 4, 5, 6])
您可能感兴趣的与本文相关的镜像
Python3.11
Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

被折叠的 条评论
为什么被折叠?