Arron Up, Aroon Dn, Aroon Oscillator
def myFunction (myData):
df = myData
col = 'Date'
groupCols = ['Name']
window=Window.partitionBy(groupCols).orderBy(df[col].asc()).rowsBetween(-11, 0)
max_value = max(df['value']).over(window)
min_value = min(df['value']).over(window)
df = df.withColumn('max', max_value)
df = df.withColumn('min', min_value)
Мне нужно найти количество строк между максимальным значением и текущим значением для каждой группы
periods_since_max =
periods_since_min =
df = df.withColumn('periods_since_max', periods_since_max)
df = df.withColumn('periods_since_min', periods_since_min)
aroon_up = ((12.0 - df['periods_since_max'])/12.0) * 100
aroon_dn = ((12.0 - df['periods_since_min'])/12.0) * 100
df = df.withColumn('aroon_up', aroon_up)
df = df.withColumn('aroon_dn', aroon_dn)
oscillator = df['aroon_up'] - df['aroon_dn']
df = df.withColumn('oscillator', oscillator)
return df