0

I have a numpy array and a list that I want to relate to each other in order to produce a second list.

List 1: 399 values. Many object names repeat multiple times, e.g.: aaabbbbccdddddddde, etc. Array 1: 38 values, all of which appear in List 1 exactly once. e.g.: abcde,etc. I extracted them from list 1 using numpy unique List 2: Here I want to count how many times each unique value in List 2 appears in List 1. e.g.: 3,4,2,8,1

The second and third lists will be put in a pandas data frame, something like this

Array 2     List 2  
  a          3
  b          4
  c          2
  d          8
  e          1

This code . . .

array1 = np.array(array1.tolist())

listCount = 0

print(sessions.count())

while listCount <= len(list1):
        list2 = (array1.count(list1[listCount]))
        listCount = listCount + 1

. . . gets me this error:

"AttributeError: 'numpy.ndarray' object has no attribute 'count'"

I'm really confused, especially since I thought I converted the array to a list.

NWWPA
  • 69
  • 1
  • 7

0 Answers0