File size: 387 Bytes
6e079c7
 
 
 
 
 
061507f
 
6e079c7
 
 
061507f
6e079c7
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import pandas as pd



def preprocess_data (df: pd.DataFrame,target_col: str="Churn") -> pd.DataFrame:
    df.columns = df.columns.str.strip()
    if 'customerID' in df.columns:
        df = df.drop(columns='customerID')
    



    if target_col in df.columns and df[target_col].dtype=="object":
        df[target_col] = df[target_col].str.strip().map({"No":0,"Yes":1})

    return df