AttributeError:模块'peakutils'没有属性'索引'

时间:2018-02-03 01:11:22

标签: python python-3.x python-2.7 peakutils

我正在尝试使用peakutils来找到峰值。这是我的代码:

import pandas as pd
import peakutils
from peakutils import *
import matplotlib.pyplot as plt

estimated_data = pd.read_csv("file", header=None)
col1 = estimated_data[:][0]  # First column data
col2 = estimated_data[:][1]  # Second column data

index = peakutils.indexes(col2, thres=0.4, min_dist=1000)

plt.plot(col1, col2, lw=0.4, alpha=0.4)
plt.plot(col1[index], col2[index], marker="o", ls="", ms=3)

plt.show()

但是,当我运行它时,它会显示错误:

Traceback (most recent call last):
  File "/Users/shengjie/Library/Mobile Documents/com~apple~CloudDocs/Coding/try.py", line 10, in <module>
    index = peakutils.indexes(col2, thres=0.4, min_dist=1000)
AttributeError: module 'peakutils' has no attribute 'indexes'

我曾尝试使用python2.7和python3.6,但无论如何都无法正常工作。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

由于您执行import peakutils,因此您不需要此行:

from peakutils import *

删除那条额外的行,它应该有效。