{"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\nimport pandas as pd\nimport seaborn as sns\nfrom matplotlib import pyplot as plt\n%matplotlib inline\nsns.set_style('whitegrid')","metadata":{"execution":{"iopub.status.busy":"2022-03-02T22:24:22.316268Z","iopub.execute_input":"2022-03-02T22:24:22.316548Z","iopub.status.idle":"2022-03-02T22:24:23.466347Z","shell.execute_reply.started":"2022-03-02T22:24:22.316517Z","shell.execute_reply":"2022-03-02T22:24:23.46556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!tree -L 2 ../input","metadata":{"execution":{"iopub.status.busy":"2022-03-02T22:24:23.468286Z","iopub.execute_input":"2022-03-02T22:24:23.468597Z","iopub.status.idle":"2022-03-02T22:24:24.255719Z","shell.execute_reply.started":"2022-03-02T22:24:23.468558Z","shell.execute_reply":"2022-03-02T22:24:24.254853Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/articles.csv\")\ncustomers = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/customers.csv\")\ntransactions = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/transactions_train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-03-02T22:24:24.257923Z","iopub.execute_input":"2022-03-02T22:24:24.258589Z","iopub.status.idle":"2022-03-02T22:25:38.085245Z","shell.execute_reply.started":"2022-03-02T22:24:24.25855Z","shell.execute_reply":"2022-03-02T22:25:38.084291Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.head(3)","metadata":{"execution":{"iopub.status.busy":"2022-03-02T22:25:38.087535Z","iopub.execute_input":"2022-03-02T22:25:38.087784Z","iopub.status.idle":"2022-03-02T22:25:38.12627Z","shell.execute_reply.started":"2022-03-02T22:25:38.087753Z","shell.execute_reply":"2022-03-02T22:25:38.125586Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.info()","metadata":{"execution":{"iopub.status.busy":"2022-03-02T22:25:38.14042Z","iopub.execute_input":"2022-03-02T22:25:38.140875Z","iopub.status.idle":"2022-03-02T22:25:38.327286Z","shell.execute_reply.started":"2022-03-02T22:25:38.140823Z","shell.execute_reply":"2022-03-02T22:25:38.326324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20,5))\nproductGroups = sns.countplot(x='product_group_name', data = articles)\n\nproductGroups.set_xticklabels(productGroups.get_xticklabels(),rotation=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-02T22:25:38.328873Z","iopub.execute_input":"2022-03-02T22:25:38.329327Z","iopub.status.idle":"2022-03-02T22:25:38.934979Z","shell.execute_reply.started":"2022-03-02T22:25:38.32927Z","shell.execute_reply":"2022-03-02T22:25:38.934133Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\" {articles.article_id.nunique()} articles\")\nprint(f\" {articles.product_code.nunique()} product codes\")\nprint(f\" {articles.prod_name.nunique()} product names\")\nprint(f\" {articles.product_type_no.nunique()} product types\")","metadata":{"execution":{"iopub.status.busy":"2022-03-02T22:25:38.936486Z","iopub.execute_input":"2022-03-02T22:25:38.937191Z","iopub.status.idle":"2022-03-02T22:25:38.97268Z","shell.execute_reply.started":"2022-03-02T22:25:38.937146Z","shell.execute_reply":"2022-03-02T22:25:38.971468Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top5 = articles['product_group_name'].value_counts().head().index.tolist()\ntop5","metadata":{"execution":{"iopub.status.busy":"2022-03-02T22:26:16.922636Z","iopub.execute_input":"2022-03-02T22:26:16.92353Z","iopub.status.idle":"2022-03-02T22:26:16.946179Z","shell.execute_reply.started":"2022-03-02T22:26:16.92346Z","shell.execute_reply":"2022-03-02T22:26:16.945064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top5Articles = articles[articles['product_group_name'].isin(top5)]","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20,20))\nchart = sns.countplot(x='product_group_name', hue = 'product_type_name',data = top5Articles)\n\nchart.set_xticklabels(chart.get_xticklabels(),rotation=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-02T22:25:39.021496Z","iopub.execute_input":"2022-03-02T22:25:39.021792Z","iopub.status.idle":"2022-03-02T22:25:43.190636Z","shell.execute_reply.started":"2022-03-02T22:25:39.02176Z","shell.execute_reply":"2022-03-02T22:25:43.189686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.options.display.max_rows = None\narticles.groupby(['product_group_name', 'product_type_name']).count().sort_values(by='article_id', ascending=False)['article_id']","metadata":{"execution":{"iopub.status.busy":"2022-03-02T22:37:06.700013Z","iopub.execute_input":"2022-03-02T22:37:06.700298Z","iopub.status.idle":"2022-03-02T22:37:06.890383Z","shell.execute_reply.started":"2022-03-02T22:37:06.700271Z","shell.execute_reply":"2022-03-02T22:37:06.889521Z"},"trusted":true},"execution_count":null,"outputs":[]}]}