How can two observation rosters become one distinct roster?

union1d flattens both inputs and returns sorted distinct values appearing in either.

numpy.union1d in practice

Two collectors both recorded ID three. The joint roster contains it once. Keep source flags separately if provenance matters later.

import numpy as np
np.union1d([3,1],[2,3])

Result [1, 2, 3]

中文

怎样合并两份观测名单并消除重复?

union1d 展平两个输入,返回至少在其中一个出现过的排序唯一值。

numpy.union1d 算例

两台采集器都记录了编号 3,合并名单时只留一份。需要知道哪台曾观测到它时,还须保存来源标记。

import numpy as np
np.union1d([3,1],[2,3])

结果 [1, 2, 3]

References / 参考来源

Keep reading / 继续阅读