Generation

generate functionSat, 25 Feb 2023

You need to split the values of the int_rate column (in str data format) into categories. Write a function that creates a rate_group column and adds values to it as follows: 1) if int_rate > 15.00%, rate_group should be '>15' 2) if int_rate is between 10.00% and 15.00%, then rate_group should be '10-15'

def rate_group(rate): if rate > 15.00: return '>15' elif rate <= 15.00 and rate > 10.00: return '10-15'

Questions about programming?Chat with your personal AI assistant