Skip to content

Instantly share code, notes, and snippets.

@jaradc
Created January 5, 2018 21:36
Show Gist options
  • Save jaradc/df5aefb64cb911beaa53f9efc8c75611 to your computer and use it in GitHub Desktop.
Save jaradc/df5aefb64cb911beaa53f9efc8c75611 to your computer and use it in GitHub Desktop.
This function scales a numpy array between two values (ex: 0.05, 1.25)
def scale_between(series, min_amt, max_amt):
series_min = series.min()
series_max = series.max()
return (((max_amt - min_amt)*(series - series_min)) / (series_max - series_min)) + min_amt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment