I have NumPy array containing string values.
For instance: ["bus", "bar", "bar", "café" .....]
What is the best way of counting the number of occurrences of each element in my array. My current solution is:
# my_list contains my data.
bincount = []
for name in set(my_list.tolist()):
count = sum([1 for elt in my_list if elt == name])
bincount.append(count)
I have tried bincount but it does not work with this type of data.
Do you know a better solution?