text_plain_output_1.png
import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train = pd.read_csv('../input/tabular-playground-series-sep-2022/train.csv')

test = pd.read_csv('../input/tabular-playground-series-sep-2022/test.csv')

df_total = train.append(test)

df_total.drop('row_id', axis=1, inplace=True)

df_total['date'] = pd.to_datetime(df_total['date'], format='%Y-%m-%d')
df_total['year'] = df_total['date'].dt.year
df_total['month'] = df_total['date'].dt.month
df_total['day'] = df_total['date'].dt.day
df_total['day_of_week'] = df_total['date'].dt.day_of_week
df_total['day_of_year'] = df_total['date'].dt.day_of_year
df_total['is_weekend'] = np.where(df_total['day_of_week'].isin([5, 6]), 1, 0)
df_total.drop('date', axis=1, inplace=True)

one_hot_encoded_data = pd.get_dummies(df_total, columns=['country', 'store', 'product'], drop_first=True)

df_train = one_hot_encoded_data[~one_hot_encoded_data.num_sold.isnull()]
df_test = one_hot_encoded_data[one_hot_encoded_data.num_sold.isnull()].drop(['num_sold'], axis=1)

X_train = df_train.drop('num_sold', axis=1)
y_train = df_train['num_sold']
X_test = df_test

X_test.shape