numpy get length of list 1

numpy get length of list

arr = np.array(['aasdfads', 'asfdads', 'fdfsdfaf'])
>>> [len(i) for i in arr]
[8, 7, 8]

Here is what the above code is Doing:
1. Create a list of strings
2. Create a new list by applying the len() function to each element of the list

Similar Posts