AttributeError: module 'peakutils' has no attribute 'indexes'

AttributeError: module 'peakutils' has no attribute 'indexes'

我正在尝试使用 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,但均无效。

有人可以帮助我吗?

既然你做了 import peakutils,你就不需要这一行:

from peakutils import *

删除多余的行,它应该可以工作。