Strange issue when storing FFT periods in Pandas dataframe
问题 I am trying to store the results of FFT calculations in a Pandas data frame: ft = pd.DataFrame(index=range(90)) ft['y'] = ft.index.map(lambda x: np.sin(2*x)) ft['spectrum'] = np.fft.fft(ft['y']) ft['freq'] = np.fft.fftfreq(len(ft.index)).real ft['T'] = ft['freq'].apply(lambda f: 1/f if f != 0 else 0) Everything seems to be working fine until the last line: the column T which is supposed to store periods has for some reason all the columns of the frame, ie.: In [499]: ft.T[0] Out[499]: y 0j