1

我正在尝试使用 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,但无论哪种方式都不起作用。

有人能帮我吗?

4

1 回答 1

0

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

from peakutils import *

删除那条额外的线,它应该可以工作。

于 2018-02-03T01:17:20.257 回答