Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A trend line sample in matplotlib Python
# 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