Length of each string in a NumPy array

后端 未结 4 918
一整个雨季
一整个雨季 2020-12-17 15:34

Is there any builtin operation in NumPy that returns the length of each string in an array?

I don\'t think any of the NumPy string operations does that, is this corr

4条回答
  •  长情又很酷
    2020-12-17 16:17

    You can use vectorize of numpy. It is much faster.

    mylen = np.vectorize(len)
    print mylen(arr)
    

提交回复
热议问题