Kaggle competition: Rossmann Store Sales
train_data = application_data[application_data.IS_TRAIN == 1].merge(train_target, how='left', on='SK_ID_CURR' )<drop_column>
train_file = '.. /input/rossmann-store-sales/train.csv'
test_file = '.. /input/rossmann-store-sales/test.csv'
output_file = 'predictions.csv'
train = pd.read_csv(train_file, low_memory=False)
 test = pd.read_csv(test_file, low_memory=False)
 print('train データ
'
'shape', train.shape)
 display(train.head())
 print('test データ：Sales だけ欠けているのでこれを予測する（回帰）．
'
'shape', test.shape)
 display(test.head())
 train_means = train.groupby([ 'Store', 'DayOfWeek', 'Promo' ])['Sales'].mean().reset_index()
print("とりあえず適当にグルーピングした平均値を予測値とすることにする．
"
"train データを店，曜日，プロモーション有無で集計
",
'shape', train_means.shape)
 display(train_means.head())
 print("test データに結合")
 test = pd.merge(test, train_means,
on = ['Store','DayOfWeek','Promo'], how='left')
 test.fillna(train.Sales.mean() , inplace=True)
 display(test.head())
 print('提出用に Id, Sales だけ抜き出す')
 submission = test[[ 'Id', 'Sales' ]]
display(submission.head())
 submission.to_csv(output_file, index = False )