|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
程序:
#!/usr/bin/env Python
#coding=utf-8
import numpy as np
import pandas as pd
from sklearn import datasets
import matplotlib.pyplot as plt
from pyhht.emd import EMD
from pyhht.visualization import plot_imfs
#载入时间序列数据
data = pd.read_csv(r'C:\Users\Administrator\Desktop\课程\赵贞玉\数据\周材料.csv',encoding='utf-8')
print(data)
#EMD经验模态分解
decomposer = EMD(data[0])
imfs = decomposer.decompose()
#绘制分解图
plot_imfs(data[0],imfs,data.index)
#保存IMFs
arr = np.vstack((imfs,data[0]))
dataframe = pd.DataFrame(arr.T)
dataframe.to_csv(r'C:\Users\Administrator\Desktop\课程\赵贞玉\数据\周材料imfs.csv',index=None,columns=None)
错误提示:
closing data
0 3148.32
1 3561.29
2 3546.21
3 3614.76
-- --
513 2521.69
514 2471.80
515 2450.03
Traceback (most recent call last):
File "D:\python\lib\site-packages\pandas\core\indexes\base.py", line 2891, in get_loc
return self._engine.get_loc(casted_key)
File "pandas\_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 1675, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 1683, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 0
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\python\program\EMD.py", line 15, in <module>
decomposer= EMD(data[0])
File "D:\python\lib\site-packages\pandas\core\frame.py", line 2902, in __getitem__
indexer = self.columns.get_loc(key)
File "D:\python\lib\site-packages\pandas\core\indexes\base.py", line 2893, in get_loc
raise keyerror(key) from err
KeyError:0 |
|