Here are the code snippet how to pick up 2 higher and lower data points from DataFrame. The computation returned only 2 sets of DataFrame rows where the data points broke above or below the calculated linear regression line in either case. but:
TypeError: import_optional_dependency() got an unexpected keyword argument 'errors' for this code
higher points are returned
while len(df_high)>2:
slope, intercept, r_value, p_value, std_err = linregress(x=df_high['Number'], y=df_high['High'])
df_high = df_high.loc[df_high['High'] > slope * df_high['Number'] + intercept]
df_high.tail()
lower points are returned
while len(df_low)>2:
slope, intercept, r_value, p_value, std_err = linregress(x=df_low['Number'], y=df_low['Low'])
df_low = df_low.loc[df_low['Low'] < slope * df_low['Number'] + intercept]
df_low.tail()