1

I have this code to make an array that shows the index of "frq_peak" that contains each elements of "F".

a =[]
for i in range(len(F)):
    if i == 0:
        a.append(np.where(frq_peak[6] == F[i]))
    elif F[i] != F[i-1]:
        a.append(np.where(frq_peak[6] == F[i]))
a

the problem is that "a" become a combination of multiple array but I want to have just one. what should I do?

Daniel Lee
  • 7,189
  • 2
  • 26
  • 44
fati
  • 41
  • 1
  • 8

1 Answers1

1

You can use this code, where your array is [[1, 2, 3], [4, 5, 6], [7, 8, 9]]:

from functools import reduce

arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

singleArray = reduce(lambda x, y: x+y, arr) 
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
NeerajSahani
  • 121
  • 1
  • 4