I have a pandas DF with datetime index with spacing = 200ms and corresponding values for each index as shown
print(filtered)
2016-07-14 16:31:19.000 -0.010054
2016-07-14 16:31:19.200 -0.011849
2016-07-14 16:31:19.400 -0.009564
2016-07-14 16:31:19.600 -0.001077
[20038 rows x 1 columns]
I want to compute the power spectral density using scipy.welch function.
f,pxx =welch(filtered.values.flatten(),5)
But when I run this line of code the power density array pxx is nan
In [897]: pxx
Out[897]:
array([ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
What is the proper way to run the welch estimation on a time series dataframe and where might I find information on what causes the welch function to output nan?
f,pxx =welch(filtered.values.flatten(),5)
works fine on my side, make sure you have no missing values in your DF and your dtypes are correct (values are floats) first.
this should work
filtered = filtered.astype(float)
filtered = filtered.dropna()
f,pxx =welch(filtered.values.flatten(),5)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.