alpertml's picture
Upload 16 files
fa10c3d verified
raw
history blame
616 Bytes
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