dy1901 / ecg_plot

Plot standard multi lead ECG/EKG chart with Python
MIT License
100 stars 48 forks source link

error key 0 #3

Closed tuxador closed 3 years ago

tuxador commented 3 years ago

Hi, i'm trying to plot a CSV file obtained from an XML my script is the following:

import ecg_plot
import pandas as pd
ecg = pd.read_csv('ecg_test.csv')
ecg_plot.plot(ecg,title = 'ECG test')
ecg_plot.show() 

and this is the error i've got:

`The above exception was the direct cause of the following exception:

   ecg_plot.plot(ecg,title = 'ECG test')
  File "/usr/lib/python3.9/site-packages/ecg_plot/ecg_plot.py", line 113, in plot
    secs  = len(ecg[0])/sample_rate
  File "/usr/lib/python3.9/site-packages/pandas/core/frame.py", line 2906, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/usr/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 2900, in get_loc
    raise KeyError(key) from err
KeyError: 0
`
dy1901 commented 3 years ago

Hi tuxador, ecg should be a numpy object in demension m x n, which m is lead count and n is length of signal. You should try to convert ecg from pandas to numpy