У меня есть вопрос о параметрах в функциях Scipy.signal.Когда я использую функцию argrelextrema в Scipy.signal, возникает ошибка: параметр 'mode' не поддерживается в реализации pandas take ().Могу ли я узнать, как это решить?Спасибо!
Я хочу найти локальные минимумы и максимумы в ценах акций за один торговый день.
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()
Могу ли я узнать, как решить эту проблему?Большое спасибо!