【发布时间】:2019-06-16 12:30:07
【问题描述】:
我正在使用 python-3.x,我想计算 numpy 数组中的重复数....例如:
import numpy as np
my_array = np.array([[2, 3, 5],
[2, 3, 5], # duplicate of row 0 (this will be count as 1)
[2, 3, 5], # duplicate of row 0 (this will be count as 2)
[1, 0, 9],
[3, 6, 6],
[3, 6, 6], # duplicate of row 0 (this will be count as 3)
[1, 0, 9]])
我想从输出中得到的是这个数组中重复的数量:
the number of the duplicate is 3
大多数方法都返回值,例如 collections.Counter 或 return_counts,如果我正确使用它们,它们不会返回我想要的。
任何建议将不胜感激
【问题讨论】:
标签: python-3.x numpy multidimensional-array duplicates