{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":31254,"databundleVersionId":3103714,"sourceType":"competition"}],"dockerImageVersionId":30746,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-08-12T15:24:25.465857Z","iopub.execute_input":"2024-08-12T15:24:25.466850Z","iopub.status.idle":"2024-08-12T15:24:25.472334Z","shell.execute_reply.started":"2024-08-12T15:24:25.466811Z","shell.execute_reply":"2024-08-12T15:24:25.470649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles_df = pd.read_csv('/kaggle/input/h-and-m-personalized-fashion-recommendations/articles.csv')\ncustomers_df = pd.read_csv('/kaggle/input/h-and-m-personalized-fashion-recommendations/customers.csv')\nsample_df = pd.read_csv('/kaggle/input/h-and-m-personalized-fashion-recommendations/sample_submission.csv')\ntransactions_df = pd.read_csv('/kaggle/input/h-and-m-personalized-fashion-recommendations/transactions_train.csv')","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:24:25.475130Z","iopub.execute_input":"2024-08-12T15:24:25.475618Z","iopub.status.idle":"2024-08-12T15:25:57.810870Z","shell.execute_reply.started":"2024-08-12T15:24:25.475564Z","shell.execute_reply":"2024-08-12T15:25:57.809641Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles_df.set_index('article_id', inplace= True)","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:25:57.835513Z","iopub.execute_input":"2024-08-12T15:25:57.836041Z","iopub.status.idle":"2024-08-12T15:25:57.854145Z","shell.execute_reply.started":"2024-08-12T15:25:57.835995Z","shell.execute_reply":"2024-08-12T15:25:57.852712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers_df","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:25:57.855914Z","iopub.execute_input":"2024-08-12T15:25:57.856413Z","iopub.status.idle":"2024-08-12T15:25:57.892355Z","shell.execute_reply.started":"2024-08-12T15:25:57.856358Z","shell.execute_reply":"2024-08-12T15:25:57.891191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transactions_df","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:25:57.895422Z","iopub.execute_input":"2024-08-12T15:25:57.895800Z","iopub.status.idle":"2024-08-12T15:25:57.911910Z","shell.execute_reply.started":"2024-08-12T15:25:57.895769Z","shell.execute_reply":"2024-08-12T15:25:57.910514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_df","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:25:57.913329Z","iopub.execute_input":"2024-08-12T15:25:57.913709Z","iopub.status.idle":"2024-08-12T15:25:57.933634Z","shell.execute_reply.started":"2024-08-12T15:25:57.913676Z","shell.execute_reply":"2024-08-12T15:25:57.932275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles_df\n","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:25:57.935153Z","iopub.execute_input":"2024-08-12T15:25:57.935629Z","iopub.status.idle":"2024-08-12T15:25:58.101976Z","shell.execute_reply.started":"2024-08-12T15:25:57.935587Z","shell.execute_reply":"2024-08-12T15:25:58.100636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"interaction_counts = transactions_df.groupby(['customer_id', 'article_id']).size().reset_index(name='interaction_count')\ninteraction_counts","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:25:58.103545Z","iopub.execute_input":"2024-08-12T15:25:58.104067Z","iopub.status.idle":"2024-08-12T15:26:28.928340Z","shell.execute_reply.started":"2024-08-12T15:25:58.104003Z","shell.execute_reply":"2024-08-12T15:26:28.926609Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transactions_df['t_dat'] = pd.to_datetime(transactions_df['t_dat'])","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:26:28.930076Z","iopub.execute_input":"2024-08-12T15:26:28.930528Z","iopub.status.idle":"2024-08-12T15:26:35.289654Z","shell.execute_reply.started":"2024-08-12T15:26:28.930493Z","shell.execute_reply":"2024-08-12T15:26:35.288484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"item_popularity = transactions_df.groupby('article_id').size().reset_index(name='popularity')","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:26:35.291191Z","iopub.execute_input":"2024-08-12T15:26:35.291577Z","iopub.status.idle":"2024-08-12T15:26:36.250347Z","shell.execute_reply.started":"2024-08-12T15:26:35.291545Z","shell.execute_reply":"2024-08-12T15:26:36.249130Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"item_popularity","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:26:36.251970Z","iopub.execute_input":"2024-08-12T15:26:36.252468Z","iopub.status.idle":"2024-08-12T15:26:36.266067Z","shell.execute_reply.started":"2024-08-12T15:26:36.252426Z","shell.execute_reply":"2024-08-12T15:26:36.264666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers_df.postal_code.duplicated()","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:26:36.267934Z","iopub.execute_input":"2024-08-12T15:26:36.268525Z","iopub.status.idle":"2024-08-12T15:26:36.733966Z","shell.execute_reply.started":"2024-08-12T15:26:36.268475Z","shell.execute_reply":"2024-08-12T15:26:36.732759Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Aggregate sales by date\ndaily_sales = transactions_df.groupby('t_dat').agg({'price': 'sum'}).reset_index()\ndaily_sales.columns = ['Date', 'Total_Sales']\n","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:26:36.735640Z","iopub.execute_input":"2024-08-12T15:26:36.736132Z","iopub.status.idle":"2024-08-12T15:26:37.501455Z","shell.execute_reply.started":"2024-08-12T15:26:36.736097Z","shell.execute_reply":"2024-08-12T15:26:37.500108Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nplt.figure(figsize=(30, 8))\nplt.plot(daily_sales['Date'], daily_sales['Total_Sales'], color='blue', marker='o', linestyle='-')\nplt.title('Total Sales Over Time')\nplt.xlabel('Date')\nplt.ylabel('Total Sales')\nplt.grid(True)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-08-12T15:30:12.268996Z","iopub.execute_input":"2024-08-12T15:30:12.269590Z","iopub.status.idle":"2024-08-12T15:30:12.852000Z","shell.execute_reply.started":"2024-08-12T15:30:12.269545Z","shell.execute_reply":"2024-08-12T15:30:12.850720Z"},"trusted":true},"execution_count":null,"outputs":[]}]}