Code:
import numpy as np
arr = [np.array(['aaaa', '12a', '1a'],dtype=object),np.array(['a', '1a', '1bb'],dtype=object),np.array(['a', '1a', '1b'],dtype=object)]
for arr1 in arr:
sum_list = []
for a in arr1:
sum = 0
for i in range(10):
sum += a.count(str(i))
sum_list.append(sum)
print(arr1,"->",sum_list)
Output:
['aaaa' '12a' '1a'] -> [0, 2, 1]
['a' '1a' '1bb'] -> [0, 1, 1]
['a' '1a' '1b'] -> [0, 1, 1]
Desired Ouput: 1. Item containing more numbers than other items. 2. In case there are more than 1 item containing same amount of numbers, take the item having bigger length. 3. In case there are more than 1 item containing same amount of numbers and having the same length, take the item having the first order.
['12a']
['1bb']
['1a']
Kindly let me know how to get desired output.
Thank you!