下面是来自pandas
数据库的一些条形码数据
737318 Sikat Botol Pigeon 4902508045506 75170
737379 Natur Manual Breast Pump 8850851860016 75170
738753 Sunlight 1232131321313 75261
739287 Bodymist bodyshop 1122334455667 75296
739677 Bodymist ale 1234567890123 75367
我想删除可疑的数据(即有太多重复或连续的数字),如1232131321313
、1122334455667
、1234567890123
等。我非常容忍误报,但希望尽可能避免误报(坏条形码)。你知道吗
作为第一步,我将使用条形码内置的验证机制,校验和。由于您的条形码似乎是GTIN条形码(特别是GTIN-13),因此可以使用this method:
如果您担心重复和连续的数字,您可以取这些数字的
np.diff
,然后使用Kolmogorov Smirnov test与三角形分布进行比较。随机数的连续数字之间的差值应遵循-10
和10
之间的三角形分布,最大值在0
将条形码转换为数组:
然后用它做一个面具
测试:
您将有大约30%的假阴性率,但是p值阈值
.5
应该可以保证您保留的值没有太多连续或重复的数字。如果你真的想确定你已经消除了任何可疑的东西,你可能还想测试实际数字对stat.uniform(scale = 10)
(消除1213141516171
和类似的)。你知道吗相关问题 更多 >
编程相关推荐