在 Python 中,numpy.unique 可以非常有效地从一维数组中删除所有重复项.
In Python numpy.unique can remove all duplicates from a 1D array, very efficiently.
1) 如何删除二维数组中的重复行或列?
1) How about to remove duplicate rows or columns in a 2D array?
2) nD 数组怎么样?
如果可能我会使用 pandas.
If possible I would use pandas.
In [1]: from pandas import *
In [2]: import numpy as np
In [3]: a = np.array([[1, 1], [2, 3], [1, 1], [5, 4], [2, 3]])
In [4]: DataFrame(a).drop_duplicates().values
Out[4]:
array([[1, 1],
[2, 3],
[5, 4]], dtype=int64)
这篇关于Python:从多维数组中删除重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在python中的感兴趣区域周围绘制一个矩形How to draw a rectangle around a region of interest in python(如何在python中的感兴趣区域周围绘制一个矩形)
如何使用 OpenCV 检测和跟踪人员?How can I detect and track people using OpenCV?(如何使用 OpenCV 检测和跟踪人员?)
如何在图像的多个矩形边界框中应用阈值?How to apply threshold within multiple rectangular bounding boxes in an image?(如何在图像的多个矩形边界框中应用阈值?)
如何下载 Coco Dataset 的特定部分?How can I download a specific part of Coco Dataset?(如何下载 Coco Dataset 的特定部分?)
根据文本方向检测图像方向角度Detect image orientation angle based on text direction(根据文本方向检测图像方向角度)
使用 Opencv 检测图像中矩形的中心和角度Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 检测图像中矩形的中心和角度)