text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train = pd.read_csv('/kaggle/input/electrical-consumption/train_6BJx641.csv')
test = pd.read_csv('/kaggle/input/electrical-consumption/test_pavJagI.csv')

train['datetime'] = pd.to_datetime(train['datetime'])
test['datetime'] = pd.to_datetime(test['datetime'])

def booleancon(x):
    if x == True:
        return 1
    else:
        return 0
def var2(x):
    if x == 'A':
        return 1
    elif x == 'B':
        return 2
    else:
        return 3
def time_pr(train):
    train = add_datepart(train, 'datetime', drop=True, time=True)
    train['datetimeIs_month_end'] = train['datetimeIs_month_end'].apply(booleancon)
    train['datetimeIs_month_start'] = train['datetimeIs_month_start'].apply(booleancon)
    train['datetimeIs_quarter_start'] = train['datetimeIs_quarter_start'].apply(booleancon)
    train['datetimeIs_quarter_end'] = train['datetimeIs_quarter_end'].apply(booleancon)
    train['datetimeIs_year_start'] = train['datetimeIs_quarter_start'].apply(booleancon)
    train['datetimeIs_year_end'] = train['datetimeIs_quarter_end'].apply(booleancon)
    train['var2'] = train['var2'].apply(var2)
    return train

pd.set_option('display.max_columns', 1000)
pd.set_option('display.max_rows', 1000)
pd.set_option('display.max_colwidth', 199)
train = time_pr(train)
test = time_pr(test)

col = []
for i in train.columns:
    if i != 'electricity_consumption' and i != 'ID' and (i != 'datetime'):
        col.append(i)

col