Element-wise string concatenation in numpy

后端 未结 5 797
萌比男神i
萌比男神i 2020-11-30 04:04

Is this a bug?

import numpy as np
a1=np.array([\'a\',\'b\'])
a2=np.array([\'E\',\'F\'])

In [20]: add(a1,a2)
Out[20]: NotImplemented

I am t

5条回答
  •  生来不讨喜
    2020-11-30 04:20

    This can (and should) be done in pure Python, as numpy also uses the Python string manipulation functions internally:

    >>> a1 = ['a','b']
    >>> a2 = ['E','F']
    >>> map(''.join, zip(a1, a2))
    ['aE', 'bF']
    

提交回复
热议问题