0

the way I did this was:

self.cleaned = []
for a in self.P[-1]:
    for b in a:
        for c in b:
            for d in c:
                self.cleaned.extend(d)

which is quite ugly and unintuitive, is there a proper way of doing this? maybe using numpy

Tissuebox
  • 1,016
  • 3
  • 14
  • 36
  • https://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python – Grimmy Jul 06 '17 at 21:32

1 Answers1

1

You can flatten directly with numpy using np.ndarray.flatten:

self.cleaned = np.array(self.P).flatten()
Moses Koledoye
  • 77,341
  • 8
  • 133
  • 139