File size: 616 Bytes
fa10c3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pandas as pd

def get_Xy(

        dataframe,

        not_include,

        cat_features,

        target='demand',

        cat_encoding='category'

    ):
    
    print('Preprocessing...')

    tmp_df = dataframe.copy()

    features = [col for col in tmp_df.columns if col not in not_include]

    if cat_encoding == 'category':
        tmp_df[cat_features] = tmp_df[cat_features].astype('category')

    X, y = tmp_df.loc[~tmp_df[target].isnull(), features], tmp_df.loc[~tmp_df[target].isnull(), target]
    X_test = tmp_df.loc[tmp_df[target].isnull(), features]

    return X, X_test, y