我有一个 numpy 数据结构如下:
[[['diaad'],
['iaadf'],
['aadfe'],
['hedbb'],
['edbbb'],
['dbbbb']],
[['gegec'],
['ehecf'],
['gecfc'],
['gadff'],
['adfef'],
['dffgc']],
[['ddddj'],
['dddjd'],
['ddjdd'],
['jfffd'],
['fgfdb'],
['ggdbb']]]
这是这样实例化的:
>>> a = np.array([[['diaad'], ['iaadf'], ['aadfe'], ['hedbb'], ['edbbb'], ['dbbbb']], [['gegec'], ['ehecf'], ['gecfc'], ['gadff'], ['adfef'], ['dffgc']], [['ddddj'], ['dddjd'], ['ddjdd'], ['jfffd'], ['fgfdb'], ['ggdbb']]])
有没有直接numpy
的方法来计算成对元素上的自定义函数?
例如,我的自定义函数被称为processPair(a,b)
. 它应该计算沿列的所有成对元素的结果,即在('diaad', 'gegec')
和('gegec', 'ddddj')
之间('diaad', 'ddddj')
。有什么建议吗?我在想这个map
功能可以实现这一点,但不完全确定如何实现。