A trend line sample in matplotlib Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment