{"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":"markdown","source":"# Kaggle Store Sales Forecast","metadata":{}},{"cell_type":"markdown","source":"## What we know about the database:\n\nIn this competition, you will predict sales for the thousands of product families sold at Favorita stores located in Ecuador. The training data includes dates, store and product information, whether that item was being promoted, as well as the sales numbers. Additional files include supplementary information that may be useful in building your models.\n\nFile Descriptions and Data Field Information\\\n**train.csv**\\\nThe training data, comprising time series of features store_nbr, family, and onpromotion as well as the target sales.\nstore_nbr identifies the store at which the products are sold.\nfamily identifies the type of product sold.\nsales gives the total sales for a product family at a particular store at a given date. Fractional values are possible since products can be sold in fractional units (1.5 kg of cheese, for instance, as opposed to 1 bag of chips).\nonpromotion gives the total number of items in a product family that were being promoted at a store at a given date.\\\n**test.csv**\\\nThe test data, having the same features as the training data. You will predict the target sales for the dates in this file.\nThe dates in the test data are for the 15 days after the last date in the training data.\nsample_submission.csv\nA sample submission file in the correct format.\\\n**stores.csv**\\\nStore metadata, including city, state, type, and cluster.\ncluster is a grouping of similar stores.\\\n**oil.csv**\\\nDaily oil price. Includes values during both the train and test data timeframes. (Ecuador is an oil-dependent country and it's economical health is highly vulnerable to shocks in oil prices.)\\\n**holidays_events.csv**\\\nHolidays and Events, with metadata\nNOTE: Pay special attention to the transferred column. A holiday that is transferred officially falls on that calendar day, but was moved to another date by the government. A transferred day is more like a normal day than a holiday. To find the day that it was actually celebrated, look for the corresponding row where type is Transfer. For example, the holiday Independencia de Guayaquil was transferred from 2012-10-09 to 2012-10-12, which means it was celebrated on 2012-10-12. Days that are type Bridge are extra days that are added to a holiday (e.g., to extend the break across a long weekend). These are frequently made up by the type Work Day which is a day not normally scheduled for work (e.g., Saturday) that is meant to payback the Bridge.\\\nAdditional holidays are days added a regular calendar holiday, for example, as typically happens around Christmas (making Christmas Eve a holiday).\\\n**Additional Notes**\\\nWages in the public sector are paid every two weeks on the 15 th and on the last day of the month. Supermarket sales could be affected by this.\nA magnitude 7.8 earthquake struck Ecuador on April 16, 2016. People rallied in relief efforts donating water and other first need products which greatly affected supermarket sales for several weeks after the earthquake.","metadata":{}},{"cell_type":"markdown","source":"## About the project\n\nAlthough this project as a part of a machine learning challenge in Kaggle, I grasped the opportunity to make a full analysis and visualization to the data to add it to my portfolio. \nAfter finishing the full analysis, I will make program a machine learning estimator with the scikit-learn tool and apply it to solve the challenge.\n\n\nThe main programing language for this project will be Python. I have also made some changes to the data with excel and Google’s Big Query SQL. For the visualization part, aside the use of matplotlib library, I will also use Tableau.\n","metadata":{}},{"cell_type":"markdown","source":"## About the company\n\nA quick overview of Favorita Corporation:\\\n**History**: \nThe Favorita Corporation began at Quito, Ecuador, in 1952 as a store that sold soaps, candles and imported items that turned into the first self-service supermarket that turned into a supermarket chain all over the western part of south and part of central America.\n\n\n**Business Diversification**: \nThe diversification of The Favorita Corporation contains three sections:\nIn the commercial section Favorita corporation has a diversified stores chains from supermarkets to toys and furniture stores.\nIn the real estate section commercial and industrial real estate.\nIn the industrial area they own they have warehouses and distribution centers for many different kinds of products, as well as a private power plant. \\\n\n**Sources:**\\\nWikipedia: [es.wikipedia.org](https://es.wikipedia.org/wiki/Corporaci%C3%B3n_Favorita)\\\nCorporación Favorita: [Company's Website](https://www.corporacionfavorita.com/en/)\n","metadata":{}},{"cell_type":"code","source":"# Getting the data ready:\n#Importing tools\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import preprocessing\n","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:55.762566Z","iopub.execute_input":"2022-08-02T17:55:55.762990Z","iopub.status.idle":"2022-08-02T17:55:55.768490Z","shell.execute_reply.started":"2022-08-02T17:55:55.762958Z","shell.execute_reply":"2022-08-02T17:55:55.767550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Importing the Databases\nholiday= pd.read_csv('../input/store-sales-time-series-forecasting/holidays_events.csv')\noil = pd.read_csv('../input/store-sales-time-series-forecasting/oil.csv')\nstores= pd.read_csv('../input/store-sales-time-series-forecasting/stores.csv')\ntransactions= pd.read_csv('../input/store-sales-time-series-forecasting/transactions.csv')\ntrain=pd.read_csv('../input/store-sales-time-series-forecasting/train.csv')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:55.784560Z","iopub.execute_input":"2022-08-02T17:55:55.785047Z","iopub.status.idle":"2022-08-02T17:55:57.606630Z","shell.execute_reply.started":"2022-08-02T17:55:55.785001Z","shell.execute_reply":"2022-08-02T17:55:57.605800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#exploring the databases:\nholiday.head()\n#holiday.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.608169Z","iopub.execute_input":"2022-08-02T17:55:57.609316Z","iopub.status.idle":"2022-08-02T17:55:57.624126Z","shell.execute_reply.started":"2022-08-02T17:55:57.609263Z","shell.execute_reply":"2022-08-02T17:55:57.622905Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#change date datatype\nholiday[\"date\"]=pd.to_datetime(holiday[\"date\"])","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.625775Z","iopub.execute_input":"2022-08-02T17:55:57.626194Z","iopub.status.idle":"2022-08-02T17:55:57.636690Z","shell.execute_reply.started":"2022-08-02T17:55:57.626127Z","shell.execute_reply":"2022-08-02T17:55:57.635633Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Removing transferred holidays to make better predictions\nholi=holiday.set_index(\"transferred\")\nhol1=holi.drop(True, )\nhol1=hol1.reset_index()\nhol1[\"date\"]=pd.to_datetime(hol1[\"date\"])\nholiday=hol1\nholiday.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.641078Z","iopub.execute_input":"2022-08-02T17:55:57.641964Z","iopub.status.idle":"2022-08-02T17:55:57.661257Z","shell.execute_reply.started":"2022-08-02T17:55:57.641925Z","shell.execute_reply":"2022-08-02T17:55:57.660345Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Reviewing transactionst\ntransactions.head()\ntransactions.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.662205Z","iopub.execute_input":"2022-08-02T17:55:57.662558Z","iopub.status.idle":"2022-08-02T17:55:57.676088Z","shell.execute_reply.started":"2022-08-02T17:55:57.662512Z","shell.execute_reply":"2022-08-02T17:55:57.675207Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#changing data types\ntransactions[\"date\"]=pd.to_datetime(transactions[\"date\"])\ntransactions[\"store_nbr\"]=transactions[\"store_nbr\"].astype(str)\ntransactions.dtypes\n#transactions.head()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-08-02T17:55:57.678019Z","iopub.execute_input":"2022-08-02T17:55:57.678469Z","iopub.status.idle":"2022-08-02T17:55:57.755601Z","shell.execute_reply.started":"2022-08-02T17:55:57.678428Z","shell.execute_reply":"2022-08-02T17:55:57.754810Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#reviewing stores\n#change dtype of store number\nstores[\"store_nbr\"]=stores[\"store_nbr\"].astype(str)\n#removed type and cluster as I couldn't find their meaning\nstores=stores.drop([\"type\",\"cluster\"],axis=1)\nstores.head()\nlen(stores)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.757046Z","iopub.execute_input":"2022-08-02T17:55:57.757627Z","iopub.status.idle":"2022-08-02T17:55:57.768286Z","shell.execute_reply.started":"2022-08-02T17:55:57.757591Z","shell.execute_reply":"2022-08-02T17:55:57.767187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#reviewing oil\n#I removed null values in excel while calculating the average of cells above and below null cell\noil = pd.read_csv('../input/oil-instore-data/oil_nNull_v1.csv')\noil[\"date\"]=pd.to_datetime(oil[\"date\"],format=\"%d/%m/%Y\")\noil.head()\n","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:00:14.803500Z","iopub.execute_input":"2022-08-02T18:00:14.804412Z","iopub.status.idle":"2022-08-02T18:00:14.826086Z","shell.execute_reply.started":"2022-08-02T18:00:14.804373Z","shell.execute_reply":"2022-08-02T18:00:14.824565Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#review train\n#correct datatype\ntrain[\"date\"]=pd.to_datetime(train[\"date\"])\ntrain[\"id\"]=train[\"id\"].astype(str)\ntrain[\"store_nbr\"]=train[\"store_nbr\"].astype(str)\ntrain.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:00:15.894382Z","iopub.execute_input":"2022-08-02T18:00:15.894865Z","iopub.status.idle":"2022-08-02T18:00:19.797785Z","shell.execute_reply.started":"2022-08-02T18:00:15.894822Z","shell.execute_reply":"2022-08-02T18:00:19.796915Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#clean checking null values\nholiday.isna()\nholiday.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:00:22.475537Z","iopub.execute_input":"2022-08-02T18:00:22.476350Z","iopub.status.idle":"2022-08-02T18:00:22.494527Z","shell.execute_reply.started":"2022-08-02T18:00:22.476288Z","shell.execute_reply":"2022-08-02T18:00:22.493560Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"stores.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:00:23.523554Z","iopub.execute_input":"2022-08-02T18:00:23.524162Z","iopub.status.idle":"2022-08-02T18:00:23.533957Z","shell.execute_reply.started":"2022-08-02T18:00:23.524111Z","shell.execute_reply":"2022-08-02T18:00:23.532626Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"oil.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:00:24.173331Z","iopub.execute_input":"2022-08-02T18:00:24.173753Z","iopub.status.idle":"2022-08-02T18:00:24.184301Z","shell.execute_reply.started":"2022-08-02T18:00:24.173719Z","shell.execute_reply":"2022-08-02T18:00:24.182944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isna().sum()\ntrain.dtypes\ntransactions.tail()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:00:24.871871Z","iopub.execute_input":"2022-08-02T18:00:24.873007Z","iopub.status.idle":"2022-08-02T18:00:25.282559Z","shell.execute_reply.started":"2022-08-02T18:00:24.872962Z","shell.execute_reply":"2022-08-02T18:00:25.281393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.loc[train[\"family\"]==\"GROCERY I\"].describe().round(decimals=3)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:01:23.154672Z","iopub.execute_input":"2022-08-02T18:01:23.155093Z","iopub.status.idle":"2022-08-02T18:01:23.846041Z","shell.execute_reply.started":"2022-08-02T18:01:23.155061Z","shell.execute_reply":"2022-08-02T18:01:23.844916Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.loc[train[\"sales\"]==124717]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:01:31.504579Z","iopub.execute_input":"2022-08-02T18:01:31.504998Z","iopub.status.idle":"2022-08-02T18:01:31.525352Z","shell.execute_reply.started":"2022-08-02T18:01:31.504961Z","shell.execute_reply":"2022-08-02T18:01:31.524319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"groceries1=train.loc[train[\"family\"]==\"GROCERY I\"]\ngroceries1.describe().round(decimals=3)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:01:33.863465Z","iopub.execute_input":"2022-08-02T18:01:33.864197Z","iopub.status.idle":"2022-08-02T18:01:34.119884Z","shell.execute_reply.started":"2022-08-02T18:01:33.864134Z","shell.execute_reply":"2022-08-02T18:01:34.118676Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(15,15))\nplt.scatter(groceries1[\"store_nbr\"],groceries1[\"sales\"])","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:01:53.332263Z","iopub.execute_input":"2022-08-02T18:01:53.332699Z","iopub.status.idle":"2022-08-02T18:01:54.161869Z","shell.execute_reply.started":"2022-08-02T18:01:53.332656Z","shell.execute_reply":"2022-08-02T18:01:54.160679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"str_2=groceries1.loc[groceries1[\"store_nbr\"]==\"2\"]\nstr2_2016=str_2.loc[(str_2[\"date\"].dt.year==2017)]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:01:56.191342Z","iopub.execute_input":"2022-08-02T18:01:56.192386Z","iopub.status.idle":"2022-08-02T18:01:56.219715Z","shell.execute_reply.started":"2022-08-02T18:01:56.192343Z","shell.execute_reply":"2022-08-02T18:01:56.218504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.scatter(str2_2016[\"date\"],str2_2016[\"sales\"])","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:01:56.421532Z","iopub.execute_input":"2022-08-02T18:01:56.422167Z","iopub.status.idle":"2022-08-02T18:01:56.808491Z","shell.execute_reply.started":"2022-08-02T18:01:56.422115Z","shell.execute_reply":"2022-08-02T18:01:56.807516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"str_2.loc[(str_2[\"date\"].dt.year==2016)&(str_2[\"sales\"]>8000)].describe().round(decimals=2)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:01:56.810178Z","iopub.execute_input":"2022-08-02T18:01:56.811202Z","iopub.status.idle":"2022-08-02T18:01:56.834384Z","shell.execute_reply.started":"2022-08-02T18:01:56.811160Z","shell.execute_reply":"2022-08-02T18:01:56.833234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"After a look at the stores information it seems like there are some outliers, but they make sense due to the fact that they are related to the earthquake relief efforts by the local community.\n","metadata":{}},{"cell_type":"code","source":"#pump up the data for the learning process\nmerged=pd.merge_ordered(train,oil,on=\"date\",fill_method=\"ffill\")\nmerged.loc[(merged[\"date\"].dt.year==2017)&(merged[\"date\"].dt.month==8)&(merged[\"date\"].dt.day>15)]\nmerged=merged.drop(merged.index[3000891:])\n#merged.groupby(by=merged[\"family\"]).count()\n","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:02:00.533200Z","iopub.execute_input":"2022-08-02T18:02:00.533580Z","iopub.status.idle":"2022-08-02T18:02:03.100222Z","shell.execute_reply.started":"2022-08-02T18:02:00.533549Z","shell.execute_reply":"2022-08-02T18:02:03.098998Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#setting family as categorical data\nencoder= preprocessing.LabelEncoder()\nmerged[\"family\"]= encoder.fit_transform(merged[\"family\"])\nmerged","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:02:03.102532Z","iopub.execute_input":"2022-08-02T18:02:03.103020Z","iopub.status.idle":"2022-08-02T18:02:04.034831Z","shell.execute_reply.started":"2022-08-02T18:02:03.102974Z","shell.execute_reply":"2022-08-02T18:02:04.033615Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#cut the training into smaller segmet to train and test\nfrom sklearn.linear_model import SGDRegressor\nfrom sklearn.ensemble import RandomForestRegressor\nfrom sklearn.model_selection import train_test_split\nfrom datetime import date\nmerged_500k=merged.iloc[0:2000000]\nmerged_500k\npd.options.mode.chained_assignment = None\n#dt.strptime(merged_500k[\"date\"], \"%Y-%m-%d\").toordinal()\nmerged_500k[\"date\"]= merged_500k['date'].apply(lambda x: x.toordinal())\nmerged_500k","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:03:24.344421Z","iopub.execute_input":"2022-08-02T18:03:24.344815Z","iopub.status.idle":"2022-08-02T18:03:33.671829Z","shell.execute_reply.started":"2022-08-02T18:03:24.344783Z","shell.execute_reply":"2022-08-02T18:03:33.670457Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X= merged_500k.drop(\"sales\",axis=1)\ny= merged_500k[\"sales\"]\nnp.random.seed(42)\n\n#split\nX_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.2)\nmodel=RandomForestRegressor()\nmodel.fit(X_train,y_train)\nmodel.score(X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:03:36.304730Z","iopub.execute_input":"2022-08-02T18:03:36.305461Z","iopub.status.idle":"2022-08-02T18:18:15.340502Z","shell.execute_reply.started":"2022-08-02T18:03:36.305411Z","shell.execute_reply":"2022-08-02T18:18:15.339391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import mean_squared_log_error\nfrom sklearn.model_selection import cross_val_score\ncv = cross_val_score(model,X,y,cv=3, scoring='r2')\n\n#y_pred= model.predict(X_test)\n#mse=mean_squared_log_error(y_test,y_pred)\n#mse","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:46:39.282078Z","iopub.execute_input":"2022-08-02T18:46:39.282524Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cv.mean()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T18:56:44.784028Z","iopub.execute_input":"2022-08-02T18:56:44.784551Z","iopub.status.idle":"2022-08-02T18:56:44.877182Z","shell.execute_reply.started":"2022-08-02T18:56:44.784450Z","shell.execute_reply":"2022-08-02T18:56:44.875594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test=pd.read_csv(\"../input/store-sales-time-series-forecasting/test.csv\")\ntest[\"date\"]\n","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.873168Z","iopub.status.idle":"2022-08-02T17:55:57.873561Z","shell.execute_reply.started":"2022-08-02T17:55:57.873376Z","shell.execute_reply":"2022-08-02T17:55:57.873395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test=pd.read_csv(\"../input/store-sales-time-series-forecasting/test.csv\")\ntest1=test\nencoder= preprocessing.LabelEncoder()\ntest[\"family\"]= encoder.fit_transform(test[\"family\"])\ntest[\"date\"]=pd.to_datetime(test[\"date\"])\ntestm=pd.merge_ordered(test,oil,on=\"date\",fill_method=\"ffill\")\ntestm.loc[(testm[\"date\"].dt.year==2017)&(testm[\"date\"].dt.month==8)&(testm[\"date\"].dt.day>=15)]\ntestm=testm.dropna()\ntestm[\"date\"]= testm['date'].apply(lambda x: x.toordinal())\nprint(test1)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.877450Z","iopub.status.idle":"2022-08-02T17:55:57.877936Z","shell.execute_reply.started":"2022-08-02T17:55:57.877726Z","shell.execute_reply":"2022-08-02T17:55:57.877748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#predict test\nsolution=model.predict(testm)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.879180Z","iopub.status.idle":"2022-08-02T17:55:57.879571Z","shell.execute_reply.started":"2022-08-02T17:55:57.879379Z","shell.execute_reply":"2022-08-02T17:55:57.879398Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"solution\n","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.881018Z","iopub.status.idle":"2022-08-02T17:55:57.881454Z","shell.execute_reply.started":"2022-08-02T17:55:57.881257Z","shell.execute_reply":"2022-08-02T17:55:57.881278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testm","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.882756Z","iopub.status.idle":"2022-08-02T17:55:57.883198Z","shell.execute_reply.started":"2022-08-02T17:55:57.882951Z","shell.execute_reply":"2022-08-02T17:55:57.882970Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"s1=testm[\"id\"]\ns2=solution\n\ns1=s1.tolist()\ns2=s2.tolist()\nd = {'id': s1, 'sales': s2}\nd=pd.DataFrame(data=d)\nd[\"id\"]=d[\"id\"].astype(int)\nd[\"id\"]=d[\"id\"].astype(str)\nd.to_csv(\"solution.csv\",index=False)\n","metadata":{"execution":{"iopub.status.busy":"2022-08-02T17:55:57.884098Z","iopub.status.idle":"2022-08-02T17:55:57.884507Z","shell.execute_reply.started":"2022-08-02T17:55:57.884321Z","shell.execute_reply":"2022-08-02T17:55:57.884339Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}