简体   繁体   English

如何从二维数组中返回每个元素的行索引?

[英]How to return the row index of each element from a 2D array?

I have a 8x10 2D array, A. I need another 2D array that stores only the row index of each element of A. How do I go about doing so?我有一个 8x10 二维数组 A。我需要另一个只存储 A 的每个元素的索引的二维数组。我 go 如何这样做? Appreciate your help!感谢你的帮助!

I think I got it!我想我明白了!

C = np.array(np.where(A))[0].reshape(10, 8)

暂无
暂无

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

相关问题 如何使用二维数组每一行的元素压缩一维数组中的每个元素? - How to zip each element from a 1D array with the elements from each row of a 2D array? 从1D重塑为2D numpy数组后,如何返回元素的位置(索引)? - How to return the position (Index) of an element after reshaping from 1D to 2D numpy array? 如何返回 python 中二维数组中元素的索引? - How to return the index of an element in a 2d array in python? 如何返回二维 NumPy 数组中最高和元素的索引? - How to return index of highest sum element in 2D NumPy array? Python with numpy:如何根据特定索引从二维数组的每一行中删除一个元素 - Python with numpy: How to delete an element from each row of a 2-D array according to a specific index 对于2d numpy数组的每一行,在第二个2d数组中获取相等行的索引 - For each row of a 2d numpy array get the index of an equal row in a second 2d array 如何通过另一个 2d 索引数组对 2d numpy-array 的每一行进行排序? - How can I sort each row of the 2d numpy-array by another 2d index-array? 在二维数组的每一行中查找最大值的索引 - Find index of max value in each row of 2D array 减去二维数组中每一行的第一个元素 - Subtracting first element of each row in a 2D array 如何在不使用嵌套 for 循环的情况下根据其索引值划分 2d numpy 数组中的每个元素? - How to divide each element in a 2d numpy array in relation to its index value without the use of nested for loops?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM