{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-09T14:03:26.693768Z","iopub.execute_input":"2022-08-09T14:03:26.694209Z","iopub.status.idle":"2022-08-09T14:03:26.702693Z","shell.execute_reply.started":"2022-08-09T14:03:26.694177Z","shell.execute_reply":"2022-08-09T14:03:26.701015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\ntrain_df = pd.read_csv('/kaggle/input/digital-turbine-auction-bid-price-prediction/train_data.csv')\nprint(train_df.shape)\ntest_df = pd.read_csv('/kaggle/input/digital-turbine-auction-bid-price-prediction/test_data.csv')\nprint(train_df.shape)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:03:27.565706Z","iopub.execute_input":"2022-08-09T14:03:27.566399Z","iopub.status.idle":"2022-08-09T14:04:08.475959Z","shell.execute_reply.started":"2022-08-09T14:03:27.566361Z","shell.execute_reply":"2022-08-09T14:04:08.474391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# %%time\n# train_df[\"eventTimestamp\"] = pd.to_datetime(train_df[\"eventTimestamp\"],unit='ms',infer_datetime_format=True)\n# print(\"train times\")\n# print(train_df[\"eventTimestamp\"].describe())\n\n# test_df[\"eventTimestamp\"] = pd.to_datetime(test_df[\"eventTimestamp\"],unit='ms',infer_datetime_format=True)\n# print(\"test times\")\n# print(test_df[\"eventTimestamp\"].describe())","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:04:08.478120Z","iopub.execute_input":"2022-08-09T14:04:08.478524Z","iopub.status.idle":"2022-08-09T14:04:12.958103Z","shell.execute_reply.started":"2022-08-09T14:04:08.478489Z","shell.execute_reply":"2022-08-09T14:04:12.955705Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:18:02.004611Z","iopub.execute_input":"2022-08-09T14:18:02.005000Z","iopub.status.idle":"2022-08-09T14:18:02.014648Z","shell.execute_reply.started":"2022-08-09T14:18:02.004967Z","shell.execute_reply":"2022-08-09T14:18:02.013360Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# imports","metadata":{}},{"cell_type":"code","source":"from matplotlib import pyplot as plt\nimport seaborn as sns\nfrom catboost import CatBoostRegressor\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import mean_squared_error ","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:04:12.961312Z","iopub.execute_input":"2022-08-09T14:04:12.961869Z","iopub.status.idle":"2022-08-09T14:04:14.322985Z","shell.execute_reply.started":"2022-08-09T14:04:12.961816Z","shell.execute_reply":"2022-08-09T14:04:14.320151Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# dataframe info stats\n\ndef stats(data):\n    \n    maxx = []\n    minn = []\n    for i in data.columns:\n        maxx.append(data[i].value_counts().max())\n        minn.append(data[i].value_counts().min())\n\n    return pd.DataFrame(\n        {'nunique': data.nunique(),\n         'len': len(data),\n\n         'types':data.dtypes,\n         'Nulls' : data.isna().sum(),\n                 # 'nunique/len': data.nunique()/len(data),\n        # 'Nullpercent' : data.isna().sum()/len(data),\n         \"Value counts Max\": maxx,\n         'Value counts Min':minn \n        },\n        columns = ['nunique', 'len','types','Nulls'#,'Nullpercent', 'nunique/len'\n                   ,\"Value counts Max\",'Value counts Min']).\\\n        sort_values(by ='nunique',ascending = False)\n\n\n\ndef countPlot(col,num = 6,hue = None):\n    sns.set(rc={'figure.figsize':(6,6)})\n    ax = sns.countplot(x=col, data=train_df, hue = hue,\n                   order=train_df[col].value_counts().iloc[:num].index)\n    \n    return plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:04:14.329587Z","iopub.execute_input":"2022-08-09T14:04:14.331351Z","iopub.status.idle":"2022-08-09T14:04:14.344873Z","shell.execute_reply.started":"2022-08-09T14:04:14.331296Z","shell.execute_reply":"2022-08-09T14:04:14.343002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:04:14.347342Z","iopub.execute_input":"2022-08-09T14:04:14.347766Z","iopub.status.idle":"2022-08-09T14:04:14.396947Z","shell.execute_reply.started":"2022-08-09T14:04:14.347730Z","shell.execute_reply":"2022-08-09T14:04:14.395576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"* Extract size data as number and add features from it, and overwrite orig","metadata":{}},{"cell_type":"code","source":"%%time\ntrain_df[[\"size1\",\"size2\"]] = train_df[\"size\"].str.split(\"x\",expand=True).astype(int)\ntest_df[[\"size1\",\"size2\"]] = test_df[\"size\"].str.split(\"x\",expand=True).astype(int)\n\ntrain_df[\"size\"] = train_df[\"size1\"].mul(train_df[\"size2\"])\ntest_df[\"size\"] = test_df[\"size1\"].mul(test_df[\"size2\"])\n## is this useful to also add?\ntrain_df[\"size_ratio\"] = train_df[\"size1\"].div(train_df[\"size2\"])\ntest_df[\"size_ratio\"] = test_df[\"size1\"].div(test_df[\"size2\"])","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:09:58.292451Z","iopub.execute_input":"2022-08-09T14:09:58.292876Z","iopub.status.idle":"2022-08-09T14:09:58.439731Z","shell.execute_reply.started":"2022-08-09T14:09:58.292844Z","shell.execute_reply":"2022-08-09T14:09:58.438407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"##### price related basic features","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:10:11.685701Z","iopub.execute_input":"2022-08-09T14:10:11.686102Z","iopub.status.idle":"2022-08-09T14:10:11.691500Z","shell.execute_reply.started":"2022-08-09T14:10:11.686070Z","shell.execute_reply":"2022-08-09T14:10:11.690136Z"}}},{"cell_type":"code","source":"train_df[\"sentPrice_div_bidFloorPrice\"] = train_df[\"sentPrice\"].div(train_df[\"bidFloorPrice\"])\ntrain_df[\"sentPrice_sub_bidFloorPrice\"] = train_df[\"sentPrice\"].sub(train_df[\"bidFloorPrice\"])\n\ntest_df[\"sentPrice_div_bidFloorPrice\"] = test_df[\"sentPrice\"].div(test_df[\"bidFloorPrice\"])\ntest_df[\"sentPrice_sub_bidFloorPrice\"] = test_df[\"sentPrice\"].sub(test_df[\"bidFloorPrice\"])","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:13:19.466346Z","iopub.execute_input":"2022-08-09T14:13:19.466835Z","iopub.status.idle":"2022-08-09T14:13:19.600642Z","shell.execute_reply.started":"2022-08-09T14:13:19.466801Z","shell.execute_reply":"2022-08-09T14:13:19.599748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:13:23.352046Z","iopub.execute_input":"2022-08-09T14:13:23.352500Z","iopub.status.idle":"2022-08-09T14:13:23.381912Z","shell.execute_reply.started":"2022-08-09T14:13:23.352461Z","shell.execute_reply":"2022-08-09T14:13:23.380669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### export","metadata":{}},{"cell_type":"code","source":"train_df.to_parquet(\"digital-turbine-auction-bid-price_train.parquet\",index=False)\ntest_df.to_parquet(\"digital-turbine-auction-bid-price_test.parquet\",index=False)","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"stats(train_df)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:04:14.435244Z","iopub.execute_input":"2022-08-09T14:04:14.436180Z","iopub.status.idle":"2022-08-09T14:04:51.772236Z","shell.execute_reply.started":"2022-08-09T14:04:14.436135Z","shell.execute_reply":"2022-08-09T14:04:51.770560Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"stats(test_df)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:04:51.773740Z","iopub.execute_input":"2022-08-09T14:04:51.774649Z","iopub.status.idle":"2022-08-09T14:04:52.006906Z","shell.execute_reply.started":"2022-08-09T14:04:51.774608Z","shell.execute_reply":"2022-08-09T14:04:52.004914Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Eda","metadata":{}},{"cell_type":"code","source":"fig, axes = plt.subplots(2, 2)\naxes = axes.ravel()\ntrain_df['unitDisplayType'].hist(figsize = (8, 8),ax=axes[0])\ntrain_df['connectionType'].hist(figsize = (8, 8),ax=axes[1])\ntrain_df['c3'].hist(figsize = (8, 8),ax=axes[2])\ntrain_df['has_won'].hist(figsize = (8, 8),ax=axes[3])\n\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:04:52.008522Z","iopub.execute_input":"2022-08-09T14:04:52.008974Z","iopub.status.idle":"2022-08-09T14:05:01.898630Z","shell.execute_reply.started":"2022-08-09T14:04:52.008931Z","shell.execute_reply":"2022-08-09T14:05:01.897401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"countPlot('countryCode',10)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:05:01.903074Z","iopub.execute_input":"2022-08-09T14:05:01.904106Z","iopub.status.idle":"2022-08-09T14:05:06.047294Z","shell.execute_reply.started":"2022-08-09T14:05:01.904062Z","shell.execute_reply":"2022-08-09T14:05:06.045784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"countPlot('winBid',10)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:05:06.049391Z","iopub.execute_input":"2022-08-09T14:05:06.049897Z","iopub.status.idle":"2022-08-09T14:05:07.575676Z","shell.execute_reply.started":"2022-08-09T14:05:06.049854Z","shell.execute_reply":"2022-08-09T14:05:07.574447Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"countPlot('sentPrice',6,'has_won')","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:05:07.577338Z","iopub.execute_input":"2022-08-09T14:05:07.578531Z","iopub.status.idle":"2022-08-09T14:05:09.815123Z","shell.execute_reply.started":"2022-08-09T14:05:07.578481Z","shell.execute_reply":"2022-08-09T14:05:09.813698Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"countPlot('mediationProviderVersion')","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:05:09.817616Z","iopub.execute_input":"2022-08-09T14:05:09.818126Z","iopub.status.idle":"2022-08-09T14:05:13.913197Z","shell.execute_reply.started":"2022-08-09T14:05:09.818081Z","shell.execute_reply":"2022-08-09T14:05:13.911188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def percentile80(x):\n    return np.percentile(x,80)\n\npivoted = train_df.pivot_table(index = ['countryCode'], values = ['winBid'], \n               aggfunc = [np.mean, np.median, np.std,'count', percentile80])\n\npivoted.columns = pivoted.columns.get_level_values(0)\n\n\npivoted.sort_values('count',ascending=False).head(17)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:05:13.915777Z","iopub.execute_input":"2022-08-09T14:05:13.917076Z","iopub.status.idle":"2022-08-09T14:05:18.817098Z","shell.execute_reply.started":"2022-08-09T14:05:13.917008Z","shell.execute_reply":"2022-08-09T14:05:18.816186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# preprocessing","metadata":{}},{"cell_type":"code","source":"# Q&D\n# try with missing\n# train_df.fillna({'connectionType':'UNKNOWN'}, inplace=True) #'countryCode':'US', \n# test_df.fillna({ 'connectionType':'UNKNOWN'}, inplace=True) # 'countryCode':'US',\ntrain_df.fillna({'countryCode':'US', 'connectionType':'UNKNOWN'}, inplace=True)\ntest_df.fillna({'countryCode':'US', 'connectionType':'UNKNOWN'}, inplace=True)\n                                    ","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:05:18.818565Z","iopub.execute_input":"2022-08-09T14:05:18.819151Z","iopub.status.idle":"2022-08-09T14:05:19.502571Z","shell.execute_reply.started":"2022-08-09T14:05:18.819116Z","shell.execute_reply":"2022-08-09T14:05:19.501394Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## TODO  fill na in country code by other columns\n\n# columns = ['brandName','correctModelName','connectionType','countryCode']\n\n# fill_null_df = train_df[columns + ['winBid']]\\\n# .groupby(columns, as_index=False,sort=True).count()\n\n# fillcountrycode = fill_null_df.sort_values(by=['brandName','correctModelName','connectionType','winBid'],ascending=False).drop_duplicates(['brandName','correctModelName','connectionType'])\n# fillconnectiontype = fill_null_df.sort_values(by=['brandName','correctModelName','countryCode','winBid'],ascending=False).drop_duplicates(['brandName','correctModelName','countryCode'])\n","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:05:19.504028Z","iopub.execute_input":"2022-08-09T14:05:19.504396Z","iopub.status.idle":"2022-08-09T14:05:19.510203Z","shell.execute_reply.started":"2022-08-09T14:05:19.504362Z","shell.execute_reply":"2022-08-09T14:05:19.508929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cols = ['c2', 'c4']\ntrain_df[cols] = train_df[cols].applymap(np.int16)\ntest_df[cols] = test_df[cols].applymap(np.int16)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T14:05:19.511790Z","iopub.execute_input":"2022-08-09T14:05:19.512223Z","iopub.status.idle":"2022-08-09T14:05:29.807812Z","shell.execute_reply.started":"2022-08-09T14:05:19.512182Z","shell.execute_reply":"2022-08-09T14:05:29.806480Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.columns","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# select columns","metadata":{}},{"cell_type":"code","source":"train_columns = [ 'unitDisplayType', 'brandName', 'bundleId',\n       'appVersion', 'correctModelName', 'countryCode',# 'deviceId',\n       'osAndVersion', 'connectionType', 'c1', 'c2', 'c3', 'c4', 'size',\n                 \"sentPrice_div_bidFloorPrice\", \"sentPrice_sub_bidFloorPrice\",\"size_ratio\",\n       'mediationProviderVersion', 'bidFloorPrice'#,'has_won'\n       ]\n\ncat_columns = [ 'unitDisplayType', 'brandName', 'bundleId',\n       'appVersion', 'correctModelName', 'countryCode', #'deviceId',\n       'osAndVersion', 'connectionType', 'c1', 'c2', 'c3', 'c4', \n#                'size',\n       'mediationProviderVersion',#'has_won'\n       ]\n\ntarget = ['winBid']","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:37:31.151494Z","iopub.execute_input":"2022-08-07T09:37:31.151974Z","iopub.status.idle":"2022-08-07T09:37:31.158603Z","shell.execute_reply.started":"2022-08-07T09:37:31.151936Z","shell.execute_reply":"2022-08-07T09:37:31.1574Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# train model","metadata":{}},{"cell_type":"code","source":"X_train, X_val, y_train, y_val = train_test_split(train_df[train_columns],train_df[target], test_size = 0.1, random_state=17) ","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:37:31.160273Z","iopub.execute_input":"2022-08-07T09:37:31.160622Z","iopub.status.idle":"2022-08-07T09:37:42.824167Z","shell.execute_reply.started":"2022-08-07T09:37:31.160587Z","shell.execute_reply":"2022-08-07T09:37:42.82306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time \n\ncboost =  CatBoostRegressor(iterations=4000,random_state=17,cat_features=cat_columns,task_type='GPU',verbose=False) # ,learning_rate = 0.1\n\n\ncboost.fit(X_train, y_train,use_best_model=True,eval_set=(X_val,  y_val),early_stopping_rounds=50,plot=True)\n# y_pred = cboost.fit(X_train, y_train).predict(X_val) # orig","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:37:42.825581Z","iopub.execute_input":"2022-08-07T09:37:42.825988Z","iopub.status.idle":"2022-08-07T09:46:39.810792Z","shell.execute_reply.started":"2022-08-07T09:37:42.825941Z","shell.execute_reply":"2022-08-07T09:46:39.809715Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# mse = mean_squared_error(y_val, y_pred)\n# np.sqrt(mse)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:46:39.812147Z","iopub.execute_input":"2022-08-07T09:46:39.813097Z","iopub.status.idle":"2022-08-07T09:46:39.835263Z","shell.execute_reply.started":"2022-08-07T09:46:39.813057Z","shell.execute_reply":"2022-08-07T09:46:39.834378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_sub = cboost.predict(test_df[train_columns])","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:46:39.837589Z","iopub.execute_input":"2022-08-07T09:46:39.838016Z","iopub.status.idle":"2022-08-07T09:46:40.448862Z","shell.execute_reply.started":"2022-08-07T09:46:39.83798Z","shell.execute_reply":"2022-08-07T09:46:40.447838Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_sub1 = y_sub.clip(0.02)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:46:40.460493Z","iopub.execute_input":"2022-08-07T09:46:40.461467Z","iopub.status.idle":"2022-08-07T09:46:40.468004Z","shell.execute_reply.started":"2022-08-07T09:46:40.461424Z","shell.execute_reply":"2022-08-07T09:46:40.467019Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# TODO bid > bidFloorPrice\n# TODO B.R","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subdf = pd.DataFrame({'deviceId':test_df['deviceId'], 'winBid':y_sub})\nsubdf1 = pd.DataFrame({'deviceId':test_df['deviceId'], 'winBid':y_sub1})\nsubdf.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:46:40.469393Z","iopub.execute_input":"2022-08-07T09:46:40.470399Z","iopub.status.idle":"2022-08-07T09:46:40.485241Z","shell.execute_reply.started":"2022-08-07T09:46:40.470363Z","shell.execute_reply":"2022-08-07T09:46:40.484342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# submission","metadata":{}},{"cell_type":"code","source":"sub_example = pd.read_csv('/kaggle/input/digital-turbine-auction-bid-price-prediction/sample_submission.csv')\nsub_example.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:46:40.487007Z","iopub.execute_input":"2022-08-07T09:46:40.487407Z","iopub.status.idle":"2022-08-07T09:46:40.518062Z","shell.execute_reply.started":"2022-08-07T09:46:40.487372Z","shell.execute_reply":"2022-08-07T09:46:40.517223Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subdf = subdf.set_index('deviceId')\nsubdf = subdf.reindex(index=sub_example['deviceId'])\nsubdf = subdf.reset_index()\nsubdf.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:46:40.520555Z","iopub.execute_input":"2022-08-07T09:46:40.521729Z","iopub.status.idle":"2022-08-07T09:46:40.545508Z","shell.execute_reply.started":"2022-08-07T09:46:40.521691Z","shell.execute_reply":"2022-08-07T09:46:40.544662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"VER = 'BL'","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:46:40.546885Z","iopub.execute_input":"2022-08-07T09:46:40.547266Z","iopub.status.idle":"2022-08-07T09:46:40.551995Z","shell.execute_reply.started":"2022-08-07T09:46:40.547198Z","shell.execute_reply":"2022-08-07T09:46:40.550949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subdf.to_csv(f'submission_{VER}.csv', index = False)","metadata":{"execution":{"iopub.status.busy":"2022-08-07T09:46:40.557632Z","iopub.execute_input":"2022-08-07T09:46:40.558397Z","iopub.status.idle":"2022-08-07T09:46:40.651193Z","shell.execute_reply.started":"2022-08-07T09:46:40.558362Z","shell.execute_reply":"2022-08-07T09:46:40.650274Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subdf1 = subdf1.set_index('deviceId')\nsubdf1 = subdf1.reindex(index=sub_example['deviceId'])\nsubdf1 = subdf1.reset_index()\nsubdf1.to_csv(f'submission_clipped_{VER}.csv', index = False)","metadata":{},"execution_count":null,"outputs":[]}]}