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

train_df = pd.read_csv('../input/store-sales-time-series-forecasting/train.csv', index_col='id')
test_df = pd.read_csv('../input/store-sales-time-series-forecasting/test.csv', index_col='id')

train_df.date = pd.to_datetime(train_df.date)
test_df.date = pd.to_datetime(test_df.date)
train_df['year'] = train_df.date.dt.year
test_df['year'] = test_df.date.dt.year
train_df['month'] = train_df.date.dt.month
test_df['month'] = test_df.date.dt.month
train_df['dayofmonth'] = train_df.date.dt.day
test_df['dayofmonth'] = test_df.date.dt.day
train_df['dayofweek'] = train_df.date.dt.dayofweek
test_df['dayofweek'] = test_df.date.dt.dayofweek
train_df['dayname'] = train_df.date.dt.strftime('%A')
test_df['dayname'] = test_df.date.dt.strftime('%A')

train_df