laszukdawid / PyEMD

Python implementation of Empirical Mode Decompoisition (EMD) method
https://pyemd.readthedocs.io/
Apache License 2.0
867 stars 224 forks source link

unclear KeyError #81

Closed paris007 closed 4 years ago

paris007 commented 4 years ago

I am getting this error with simple lines of code emd = EMD() CST = df_baseline['CST'] Time = df_baseline['Time'] IMFs = emd(CST, Time)

/Users/paris/.pyenv/versions/anaconda3-2019.10/lib/python3.7/site-packages/numpy/core/fromnumeric.py:61: FutureWarning: Series.nonzero() is deprecated and will be removed in a future version.Use Series.to_numpy().nonzero() instead return bound(*args, **kwds) Traceback (most recent call last): File "breathingProcessing.py", line 93, in IMFs = emd(CST, Time) File "/Users/paris/.pyenv/versions/anaconda3-2019.10/lib/python3.7/site-packages/PyEMD/EMD.py", line 108, in call return self.emd(S, T=T, max_imf=max_imf) File "/Users/paris/.pyenv/versions/anaconda3-2019.10/lib/python3.7/site-packages/PyEMD/EMD.py", line 808, in emd max_env, min_env, eMax, eMin = self.extract_max_min_spline(T, imf) File "/Users/paris/.pyenv/versions/anaconda3-2019.10/lib/python3.7/site-packages/PyEMD/EMD.py", line 139, in extract_max_min_spline pp_res = self.prepare_points(T, S, max_pos, max_val, min_pos, min_val) File "/Users/paris/.pyenv/versions/anaconda3-2019.10/lib/python3.7/site-packages/PyEMD/EMD.py", line 178, in prepare_points return self._prepare_points_simple(T, S, max_pos, max_val, min_pos, min_val) File "/Users/paris/.pyenv/versions/anaconda3-2019.10/lib/python3.7/site-packages/PyEMD/EMD.py", line 342, in _prepare_points_simple if S[-1] < S[ind_max[-1]]: File "/Users/paris/.pyenv/versions/anaconda3-2019.10/lib/python3.7/site-packages/pandas/core/series.py", line 1068, in getitem result = self.index.get_value(self, key) File "/Users/paris/.pyenv/versions/anaconda3-2019.10/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 4730, in get_value return self._engine.get_value(s, k, tz=getattr(series.dtype, "tz", None)) File "pandas/_libs/index.pyx", line 80, in pandas._libs.index.IndexEngine.get_value File "pandas/_libs/index.pyx", line 88, in pandas._libs.index.IndexEngine.get_value File "pandas/_libs/index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/hashtable_class_helper.pxi", line 992, in pandas._libs.hashtable.Int64HashTable.get_item File "pandas/_libs/hashtable_class_helper.pxi", line 998, in pandas._libs.hashtable.Int64HashTable.get_item KeyError: -

Thank you for your help in advance

paris007 commented 4 years ago

I figured it out. The signal has to be an np type not a dataframe

    IMFs = emd(CST.to_numpy(), Time.to_numpy())

and it worked

laszukdawid commented 4 years ago

Yep, that's correct :)