Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Created September 29, 2020 07:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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