Created
June 16, 2019 12:17
-
-
Save admond1994/81f6a3c714e02b2dd6665267eeafb5c3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def get_discrete_intervals_from_values(df): | |
| ''' | |
| AIM -> get discrete intervals by binning values to a range | |
| INPUT -> df | |
| OUTPUT -> updated df with discrete intervals based on numerical values | |
| ------ | |
| ''' | |
| df['rating'] = pd.cut(df['rating'], | |
| bins=[-1,3,5,7,10], | |
| labels=['bad','moderate','good','strong']) | |
| return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment