Created
October 29, 2018 23:43
-
-
Save amrakm/24f7b459a006629c3e53f1cb55e24962 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
ranges = [0,50,100,160] | |
ranges_label = ['cheap', "average", "expensive"] | |
df['price_cat'] = pd.cut(df.current_package_price, ranges, labels=ranges_label) | |
# Another example | |
# Bucketing age groups | |
ranges = [18,25,29,34, 50,70, 2020] | |
ranges_label = ['18-25','26-29',"30-34", "35-50", '51-70','unknown'] | |
df['age_group'] = pd.cut(df['age'], ranges, labels=ranges_label) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment