Putting the loop inside of loop properly

Isaac Won winefrog at gmail.com
Fri Mar 1 19:07:26 CET 2013

I just would like to make my previous question simpler and I bit adjusted my code with help with Ulich and Chris.
The basic structure of my code is:

for c in range(5,25):

        for columns in ( raw.strip().split() for raw in f ):
                x = np.array(a, float)
        not_nan = np.logical_not(np.isnan(x))
        indices = np.arange(len(x))
        interp = interp1d(indices[not_nan], x[not_nan], kind = 'nearest')
        p = interp(indices)

        N = len(p)

        fpsd = plot_freq*PSD
        for d in range(336):

                y = fpsd[d]
                y1 = y1 + [y]
                m = np.mean(y1)
        m1 = m1 + [m]
I just removed seemingly unnecesary lines. I expect that last loop can produce the each order values (first, second,.... last(336th)) of fpsd from former loop.
fpsd would be 20 lists. So, fpsd[0] in third loop shoul be first values from 20 lists and it expects to be accumulated to y1. So, y1 should be the list of first values from 20 fpsd lists. and m is mean of y1. I expect to repeat 356 times and accumulated to m1. However, it doesn't work and fpsd values in and out of the last loop are totally different.
My question is clear?
Any help or questions would be really appreciated.

More information about the Python-list mailing list