Python Numpy 值错误:操作数无法与形状一起广播 (122,) (112,)

问题描述

我正在尝试使用 scipy.signal 中的 find_peaks 来检测 Python 3.7 中的峰值和谷值

import pandas as pd
from scipy.signal import find_peaks
import numpy as np
import matplotlib.pyplot as plt

df = pd.read_excel('a44171.xlsx',header=None)
df.columns = ['II','PLETH','ABP']
ppg = df["PLETH"]

series = np.array(ppg)
fs = 1/60
t = np.array([t*fs for t in range(len(series))])

peak_idx,_ = find_peaks(series,distance=60)
valley_idx,_ = find_peaks(-series,distance=60)

timedelay = peak_idx - valley_idx

我收到以下错误

ValueError: operands Could not be broadcast together with shapes (122,) (112,)

我猜有一些缺失的峰,所以尺寸不同。 有没有我可以添加代码来修复错误

请帮忙!我是 Python 编程的新手。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)