{"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":"\nimport pandas as pd\n\ntrain = pd.read_pickle('../input/matchfinal/train.pkl')\ntest = pd.read_csv('../input/foursquare-location-matching/test.csv',dtype=\"str\")\n\ncols = ['id']\ntest = test.merge(train[cols+['point_of_interest']], on=cols, how='left')\ntest[['id', 'point_of_interest']].to_csv('id2poi.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-08T22:57:53.811651Z","iopub.execute_input":"2022-07-08T22:57:53.81209Z","iopub.status.idle":"2022-07-08T22:58:00.272321Z","shell.execute_reply.started":"2022-07-08T22:57:53.812056Z","shell.execute_reply":"2022-07-08T22:58:00.271346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"id2poi = pd.read_csv('id2poi.csv')\n\nmatch_dict = {}\nfor poi, group_df in id2poi.groupby('point_of_interest'):\n    ids = set(group_df['id'].tolist())\n    for id_str in ids:\n        match_dict[id_str] = \" \".join(ids)\n\nsubmission = pd.read_csv('../input/foursquare-location-matching/test.csv', dtype=str).fillna('[NAN]')[[\"id\"]]\nsubmission[\"matches\"]=submission[\"id\"].apply(lambda x:match_dict.get(x,x))\nsubmission.to_csv('submission.csv', index = False)","metadata":{"execution":{"iopub.status.busy":"2022-07-08T22:58:00.274799Z","iopub.execute_input":"2022-07-08T22:58:00.275467Z","iopub.status.idle":"2022-07-08T22:58:00.291737Z","shell.execute_reply.started":"2022-07-08T22:58:00.275432Z","shell.execute_reply":"2022-07-08T22:58:00.291002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test","metadata":{"execution":{"iopub.status.busy":"2022-07-09T02:33:52.958312Z","iopub.execute_input":"2022-07-09T02:33:52.95925Z","iopub.status.idle":"2022-07-09T02:33:53.036427Z","shell.execute_reply.started":"2022-07-09T02:33:52.959153Z","shell.execute_reply":"2022-07-09T02:33:53.035207Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission","metadata":{"execution":{"iopub.status.busy":"2022-07-08T22:58:00.293059Z","iopub.execute_input":"2022-07-08T22:58:00.293408Z","iopub.status.idle":"2022-07-08T22:58:00.306508Z","shell.execute_reply.started":"2022-07-08T22:58:00.293375Z","shell.execute_reply":"2022-07-08T22:58:00.305498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test","metadata":{"execution":{"iopub.status.busy":"2022-07-08T10:07:54.531853Z","iopub.execute_input":"2022-07-08T10:07:54.532308Z","iopub.status.idle":"2022-07-08T10:07:54.553122Z","shell.execute_reply.started":"2022-07-08T10:07:54.532241Z","shell.execute_reply":"2022-07-08T10:07:54.552006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}