Scipy信号Argrelextrema模式参数

2024-06-16 14:18:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个问题的参数Scipy.信号功能。在中使用argrelextrema函数时Scipy.信号,出现错误:take()的实现中不支持'mode'参数。我能知道怎么解决吗?谢谢您!你知道吗

我想找出一个交易日内股票价格的局部极小值和极大值。你知道吗

import numpy as np
import pandas as pd
from scipy.signal import find_peaks, argrelmin

def vmap(data):
    volume = data.volume
    price = data.price
    return data.assign(vmap = (volume * price).cumsum() / volume.cumsum())

# load data
today_single_data_file = np.load(data_dir + '/1_18_2018.npz')
index = pd.date_range('1/18/2018 09:30:00', '1/18/2018 16:30:00', freq= 'S')
today_price_file = pd.DataFrame(today_single_data_file[symbols[1]],
                                index = index[:len(today_single_data_file[symbols[1]][:,0])],
                                columns= ['price', 'volume'])

# convert cumulative volume to volume by second, calculate vmap
today_price_file['volume'] = today_price_file['volume'].diff(periods=1)
today_price_file = today_price_file.groupby(today_price_file.index.date, group_keys=False).apply(vmap)

# resample to 30s interval
aggAvg = today_price_file.resample('30S').mean()

# find local minima and maxima
maxima, _ = find_peaks(aggAvg.price, distance= params['num_adjacent'][0], threshold= 0.02)
minima = argrelmin(aggAvg.price, order = params['num_adjacent'][0], mode='clip')

当我运行程序时,它显示:

ValueError: the 'mode' parameter is not supported in the pandas implementation of take()

我可以知道如何解决这个问题吗?非常感谢你!你知道吗


Tags: importdata参数todayindexmodescipyfind