File size: 538 Bytes
69e91b1
 
1cbf62f
 
 
 
06236da
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Used during prepprocessing to fix the sugar content values 
# that are incorrectly represented as "reg" instead of "Regular" in the dataset
def fix_sugar_content(X):
    X = X.copy()
    X["Product_Sugar_Content"] = X["Product_Sugar_Content"].replace("reg", "Regular")
    return X

# Feature engineering function to create a new feature for the 
# product ID prefix contained in the first two characters of the Product_Id
def add_product_id_prefix(X):
    X = X.copy()
    X["Product_Id_Prefix"] = X["Product_Id"].str[:2]
    return X