{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport plotly.express as px\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\nimport matplotlib.pyplot as plt\nimport os\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\npd.options.display.float_format = '{:.4f}'.format\n\ndef get_row(n_total, n_cols) :\n    if n_total % n_cols == 0 :\n        n_rows = n_total / n_cols\n    else :\n        n_rows = (n_total // n_cols) + 1\n    return int(n_rows)\n\ndef visualize_articles(articles , article_list, n_total , n_cols , figsize=(25,10)) :\n    n_rows = get_row(n_total , n_cols)\n    f, ax = plt.subplots(n_rows, n_cols, figsize=figsize)\n    axes = ax.flatten()\n    i = 0\n    for article in article_list:\n        visualize_article(axes , i , articles , article)\n        i += 1\n    else :\n        plt.show()\n\n\ndef visualize_article(axes,i, articles , article) :\n    desc = articles[articles['article_id'] == article]['detail_desc'].iloc[0]\n    desc_list = desc.split(' ')\n    for j, elem in enumerate(desc_list):\n        if j > 0 and j % 5 == 0:\n            desc_list[j] = desc_list[j] + '\\n'\n    desc = ' '.join(desc_list)\n    try :\n        img = mpimg.imread(f'../input/h-and-m-personalized-fashion-recommendations/images/0{str(article)[:2]}/0{int(article)}.jpg')\n        axes[i].imshow(img)\n    except :\n        pass\n    axes[i].set_xticks([], [])\n    axes[i].set_yticks([], [])\n    axes[i].set_title(article)\n    axes[i].grid(False)\n    axes[i].set_xlabel(desc, fontsize=10)\n    \n    \n    \n\ndef check_count(a,b,a_name=\"\" , b_name=\"\") :\n    itersection_set = set(a) & set(b)\n    a_uni_set = set(a).difference(set(b))\n    b_uni_set = set(b).difference(set(a))\n    print(\"=\"*20)\n    print(a_name , len(a))\n    print(b_name , len(b))\n    print(a_name , \"unique_set\" , len(a_uni_set))\n    print(b_name , \"unique_set\" , len(b_uni_set))\n    print(\"intersection\" , len(itersection_set))\n    print(\"=\"*20)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-03-15T15:32:09.823206Z","iopub.execute_input":"2022-03-15T15:32:09.823903Z","iopub.status.idle":"2022-03-15T15:32:09.840632Z","shell.execute_reply.started":"2022-03-15T15:32:09.823866Z","shell.execute_reply":"2022-03-15T15:32:09.839831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_submission_path = \"/kaggle/input/h-and-m-personalized-fashion-recommendations/sample_submission.csv\"\ndata_article_path = \"/kaggle/input/h-and-m-personalized-fashion-recommendations/articles.csv\"\ndata_transaction_path = \"/kaggle/input/h-and-m-personalized-fashion-recommendations/transactions_train.csv\"\ndata_customer_path = \"/kaggle/input/h-and-m-personalized-fashion-recommendations/customers.csv\"","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:32:17.158033Z","iopub.execute_input":"2022-03-15T15:32:17.158280Z","iopub.status.idle":"2022-03-15T15:32:17.162274Z","shell.execute_reply.started":"2022-03-15T15:32:17.158252Z","shell.execute_reply":"2022-03-15T15:32:17.161625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"check submission\n\n* The transaction table does not contain all of the customer IDs in the submission table.\n\n**In my opinion, a different approach is needed for customers who are not included.**","metadata":{}},{"cell_type":"markdown","source":"# Customer","metadata":{}},{"cell_type":"code","source":"customer = pd.read_csv(data_customer_path,usecols = ['customer_id'])\ncustomer.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:32:20.726943Z","iopub.execute_input":"2022-03-15T15:32:20.727194Z","iopub.status.idle":"2022-03-15T15:32:25.371617Z","shell.execute_reply.started":"2022-03-15T15:32:20.727167Z","shell.execute_reply":"2022-03-15T15:32:25.370947Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer = pd.read_csv(data_customer_path,usecols = ['customer_id','age','club_member_status',\"Active\"])\npd.DataFrame(customer['age'].describe()).T","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:32:34.946832Z","iopub.execute_input":"2022-03-15T15:32:34.947442Z","iopub.status.idle":"2022-03-15T15:32:37.252508Z","shell.execute_reply.started":"2022-03-15T15:32:34.947402Z","shell.execute_reply":"2022-03-15T15:32:37.251813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for bins in np.arange(50,100,10) :\n    customer[\"age\"].plot.hist(bins=bins,density =True,alpha=0.5)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:32:40.392137Z","iopub.execute_input":"2022-03-15T15:32:40.392737Z","iopub.status.idle":"2022-03-15T15:32:41.736761Z","shell.execute_reply.started":"2022-03-15T15:32:40.392701Z","shell.execute_reply":"2022-03-15T15:32:41.736118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Age Binning","metadata":{}},{"cell_type":"code","source":"labels = [\"10\",\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\"]\nlabels_number = [int(label) for label in labels]\nlabels = [f\"{label}'s\" for label in labels]\nd = pd.cut(customer[\"age\"],labels_number,include_lowest=True, right=False, labels=labels[:-1])\ncustomer[\"age_binned\"] = pd.Categorical(d , categories=labels[:-1], ordered=True)","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:32:48.279165Z","iopub.execute_input":"2022-03-15T15:32:48.279728Z","iopub.status.idle":"2022-03-15T15:32:48.327479Z","shell.execute_reply.started":"2022-03-15T15:32:48.279689Z","shell.execute_reply":"2022-03-15T15:32:48.326750Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer[\"age_binned\"].value_counts(sort=False)","metadata":{"execution":{"iopub.status.busy":"2022-03-15T09:29:36.104733Z","iopub.execute_input":"2022-03-15T09:29:36.105242Z","iopub.status.idle":"2022-03-15T09:29:36.119403Z","shell.execute_reply.started":"2022-03-15T09:29:36.10521Z","shell.execute_reply":"2022-03-15T09:29:36.118573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer[\"age_binned\"].value_counts(sort=False).plot.barh()","metadata":{"execution":{"iopub.status.busy":"2022-03-15T10:59:08.603117Z","iopub.execute_input":"2022-03-15T10:59:08.603774Z","iopub.status.idle":"2022-03-15T10:59:08.801603Z","shell.execute_reply.started":"2022-03-15T10:59:08.603734Z","shell.execute_reply":"2022-03-15T10:59:08.800908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer.query(\"age != age\").shape","metadata":{"execution":{"iopub.status.busy":"2022-03-15T09:32:53.526953Z","iopub.execute_input":"2022-03-15T09:32:53.527253Z","iopub.status.idle":"2022-03-15T09:32:53.551581Z","shell.execute_reply.started":"2022-03-15T09:32:53.527204Z","shell.execute_reply":"2022-03-15T09:32:53.550731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer_binned = customer","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:33:24.911564Z","iopub.execute_input":"2022-03-15T15:33:24.911815Z","iopub.status.idle":"2022-03-15T15:33:24.915674Z","shell.execute_reply.started":"2022-03-15T15:33:24.911786Z","shell.execute_reply":"2022-03-15T15:33:24.914965Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer.columns","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:33:23.317905Z","iopub.execute_input":"2022-03-15T15:33:23.318329Z","iopub.status.idle":"2022-03-15T15:33:23.325190Z","shell.execute_reply.started":"2022-03-15T15:33:23.318275Z","shell.execute_reply":"2022-03-15T15:33:23.324544Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer['club_member_status'].unique()","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:33:28.055505Z","iopub.execute_input":"2022-03-15T15:33:28.056043Z","iopub.status.idle":"2022-03-15T15:33:28.185647Z","shell.execute_reply.started":"2022-03-15T15:33:28.056004Z","shell.execute_reply":"2022-03-15T15:33:28.184956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer.groupby([\"age_binned\",\"club_member_status\"]).size().plot(kind = \"bar\")","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:33:32.998240Z","iopub.execute_input":"2022-03-15T15:33:32.998811Z","iopub.status.idle":"2022-03-15T15:33:33.526805Z","shell.execute_reply.started":"2022-03-15T15:33:32.998773Z","shell.execute_reply":"2022-03-15T15:33:33.526155Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Special Customer (no transactions)\n\n* these customers does not have a transaction information.\n\n**Let's analyze these customers!**","metadata":{}},{"cell_type":"code","source":"a = check_customer.groupby([\"age_binned\",\"Active\"]).size().reset_index()\na = a[a[0] > 0]","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:33:37.224801Z","iopub.execute_input":"2022-03-15T15:33:37.225282Z","iopub.status.idle":"2022-03-15T15:33:37.244755Z","shell.execute_reply.started":"2022-03-15T15:33:37.225244Z","shell.execute_reply":"2022-03-15T15:33:37.243813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total_n = len(list(a.age_binned.unique()))\nn_cols = 4\nn_rows = get_row(total_n , n_cols)\nfigsize = (15,6)\nf, ax = plt.subplots(n_rows, n_cols, figsize=figsize)\naxes = ax.flatten()\ni = 0\nfor age_binned in list(a.age_binned.unique()) :\n    table = a[a.age_binned.str.contains(age_binned)].drop(\"age_binned\",axis=1).set_index(\"Active\")\n    table = pd.Series(table.values.squeeze(),index= table.index)\n    colors = sns.color_palette('Paired')\n    axes[i].pie(table, \n           labels=[f\"Active : {int(i)}\" for i in table.index.tolist()],\n           autopct='%1.1f%%',shadow=True, startangle=90, colors=colors)\n    axes[i].axis('equal')\n    axes[i].set_title(age_binned)\n    i += 1\nelse :\n    plt.show()\n\n","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:21:10.284287Z","iopub.execute_input":"2022-03-08T14:21:10.284607Z","iopub.status.idle":"2022-03-08T14:21:11.153872Z","shell.execute_reply.started":"2022-03-08T14:21:10.284576Z","shell.execute_reply":"2022-03-08T14:21:11.153058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# We will see if there is any seasonality","metadata":{}},{"cell_type":"code","source":"article = pd.read_csv('../input/h-and-m-personalized-fashion-recommendations/articles.csv')\ntransaction = pd.read_csv('../input/h-and-m-personalized-fashion-recommendations/transactions_train.csv')","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:33:43.807500Z","iopub.execute_input":"2022-03-15T15:33:43.807758Z","iopub.status.idle":"2022-03-15T15:34:45.076371Z","shell.execute_reply.started":"2022-03-15T15:33:43.807730Z","shell.execute_reply":"2022-03-15T15:34:45.075576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#We will join with article id\narticle_and_transaction =  pd.merge(article[['article_id','product_type_name']],transaction[['article_id','t_dat']],on='article_id')","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:35:08.524959Z","iopub.execute_input":"2022-03-15T15:35:08.525204Z","iopub.status.idle":"2022-03-15T15:35:16.467708Z","shell.execute_reply.started":"2022-03-15T15:35:08.525168Z","shell.execute_reply":"2022-03-15T15:35:16.466969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_and_transaction['year'] = pd.DatetimeIndex(article_and_transaction['t_dat']).year\narticle_and_transaction['month'] = pd.DatetimeIndex(article_and_transaction['t_dat']).month","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:35:19.333442Z","iopub.execute_input":"2022-03-15T15:35:19.334194Z","iopub.status.idle":"2022-03-15T15:35:41.118573Z","shell.execute_reply.started":"2022-03-15T15:35:19.334157Z","shell.execute_reply":"2022-03-15T15:35:41.117811Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_and_transaction.head(4)","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:35:53.128338Z","iopub.execute_input":"2022-03-15T15:35:53.128663Z","iopub.status.idle":"2022-03-15T15:35:53.143757Z","shell.execute_reply.started":"2022-03-15T15:35:53.128624Z","shell.execute_reply":"2022-03-15T15:35:53.142876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from statsmodels.graphics.mosaicplot import mosaic","metadata":{"execution":{"iopub.status.busy":"2022-03-15T13:43:42.32189Z","iopub.execute_input":"2022-03-15T13:43:42.322145Z","iopub.status.idle":"2022-03-15T13:43:42.343043Z","shell.execute_reply.started":"2022-03-15T13:43:42.322118Z","shell.execute_reply":"2022-03-15T13:43:42.342369Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_and_transaction_by_yr =  article_and_transaction.groupby(['product_type_name', 'year']).size().reset_index(name ='Total Amount')\ng = article_and_transaction_by_yr.groupby([\"product_type_name\"]).apply(lambda x: x.sort_values([\"Total Amount\"], ascending = False)).reset_index(drop=True)\ng = g.groupby('year').head(20).reset_index(drop=True)\ng = g.sort_values('year')\n","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:39:30.622753Z","iopub.execute_input":"2022-03-15T15:39:30.623031Z","iopub.status.idle":"2022-03-15T15:39:34.705497Z","shell.execute_reply.started":"2022-03-15T15:39:30.623000Z","shell.execute_reply":"2022-03-15T15:39:34.704733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.treemap(g, path=['product_type_name', 'year'], values='Total Amount')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:36:03.403130Z","iopub.execute_input":"2022-03-15T15:36:03.403739Z","iopub.status.idle":"2022-03-15T15:36:04.266384Z","shell.execute_reply.started":"2022-03-15T15:36:03.403702Z","shell.execute_reply":"2022-03-15T15:36:04.265703Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Most of the times 2019 has been the most lucerative year when it comes to number of sales\n\n# Baby Bib has increased sales in 2020 but we dont have lot of samples\n\n# Bucket hat has also increased in sales\n\n\n\n ","metadata":{}},{"cell_type":"code","source":"# We are only taking the top 10 per month\narticle_and_transaction_by_month =  article_and_transaction.groupby(['product_type_name', 'month']).size().reset_index(name ='Total Amount')\ng = article_and_transaction_by_month.groupby([\"product_type_name\"]).apply(lambda x: x.sort_values([\"Total Amount\"], ascending = False)).reset_index(drop=True)\ng = g.groupby('month').head(20).reset_index(drop=True)\ng = g.sort_values('month')","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:44:50.616114Z","iopub.execute_input":"2022-03-15T15:44:50.616408Z","iopub.status.idle":"2022-03-15T15:44:54.964695Z","shell.execute_reply.started":"2022-03-15T15:44:50.616378Z","shell.execute_reply":"2022-03-15T15:44:54.963878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.treemap(g, path=['product_type_name', 'month'], values='Total Amount')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:44:57.612646Z","iopub.execute_input":"2022-03-15T15:44:57.612901Z","iopub.status.idle":"2022-03-15T15:44:57.717552Z","shell.execute_reply.started":"2022-03-15T15:44:57.612871Z","shell.execute_reply":"2022-03-15T15:44:57.716806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# We dont see a lot of Blazers being bought on Winters","metadata":{}},{"cell_type":"markdown","source":"# We see which color is being most preferred and if it has any relation with season","metadata":{}},{"cell_type":"code","source":"#We will join with article id\narticle_and_transaction_color =  pd.merge(article[['article_id','colour_group_name']],transaction[['article_id','t_dat']],on='article_id')","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:47:41.213797Z","iopub.execute_input":"2022-03-15T15:47:41.214054Z","iopub.status.idle":"2022-03-15T15:47:49.040098Z","shell.execute_reply.started":"2022-03-15T15:47:41.214025Z","shell.execute_reply":"2022-03-15T15:47:49.039333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_and_transaction_color['colour_group_name'].value_counts()[:10].plot(kind='pie')\n","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:47:57.346327Z","iopub.execute_input":"2022-03-15T15:47:57.346605Z","iopub.status.idle":"2022-03-15T15:48:01.616070Z","shell.execute_reply.started":"2022-03-15T15:47:57.346567Z","shell.execute_reply":"2022-03-15T15:48:01.615207Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# We will not see if we have relationship with month of the year and color people wear","metadata":{}},{"cell_type":"code","source":"article_and_transaction_color['year'] = pd.DatetimeIndex(article_and_transaction_color['t_dat']).year\narticle_and_transaction_color['month'] = pd.DatetimeIndex(article_and_transaction_color['t_dat']).month\n# We are only taking the top 10 per month\narticle_and_transaction_color_by_month =  article_and_transaction_color.groupby(['colour_group_name', 'month']).size().reset_index(name ='Freq')\ng = article_and_transaction_color_by_month.groupby([\"colour_group_name\"]).apply(lambda x: x.sort_values([\"Freq\"], ascending = False)).reset_index(drop=True)\ng = g.groupby('month').head(15).reset_index(drop=True)\ng = g.sort_values('month')","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:48:01.722948Z","iopub.execute_input":"2022-03-15T15:48:01.723195Z","iopub.status.idle":"2022-03-15T15:48:28.113142Z","shell.execute_reply.started":"2022-03-15T15:48:01.723166Z","shell.execute_reply":"2022-03-15T15:48:28.112422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.treemap(g, path=['colour_group_name', 'Freq'], values='month')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-15T15:48:31.433880Z","iopub.execute_input":"2022-03-15T15:48:31.434128Z","iopub.status.idle":"2022-03-15T15:48:31.526465Z","shell.execute_reply.started":"2022-03-15T15:48:31.434100Z","shell.execute_reply":"2022-03-15T15:48:31.525685Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Most of the times the colors have usual pattern where End of the year there is increase which only tells that there is increase in sales and hence the increase in color freq","metadata":{}},{"cell_type":"code","source":"article_and_transaction_color","metadata":{"execution":{"iopub.status.busy":"2022-03-15T14:15:22.125754Z","iopub.execute_input":"2022-03-15T14:15:22.126067Z","iopub.status.idle":"2022-03-15T14:15:22.148094Z","shell.execute_reply.started":"2022-03-15T14:15:22.126033Z","shell.execute_reply":"2022-03-15T14:15:22.147467Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,usecols=[\"product_type_name\"])\ntable = pd.Categorical(d.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(21,4), rot=90)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-15T13:57:24.525437Z","iopub.execute_input":"2022-03-15T13:57:24.526107Z","iopub.status.idle":"2022-03-15T13:57:26.382774Z","shell.execute_reply.started":"2022-03-15T13:57:24.526072Z","shell.execute_reply":"2022-03-15T13:57:26.382065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,usecols=[\"graphical_appearance_name\"])\ntable = pd.Categorical(d.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(16,4), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-15T13:57:42.774986Z","iopub.execute_input":"2022-03-15T13:57:42.775266Z","iopub.status.idle":"2022-03-15T13:57:43.483908Z","shell.execute_reply.started":"2022-03-15T13:57:42.775224Z","shell.execute_reply":"2022-03-15T13:57:43.483137Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,usecols=[\"colour_group_name\"])\ntable = pd.Categorical(d.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(16,4), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:57:39.760067Z","iopub.status.idle":"2022-03-07T08:57:39.760381Z","shell.execute_reply.started":"2022-03-07T08:57:39.760218Z","shell.execute_reply":"2022-03-07T08:57:39.76024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,usecols=[\"perceived_colour_value_name\"])\ntable = pd.Categorical(d.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(16,4), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:57:39.761565Z","iopub.status.idle":"2022-03-07T08:57:39.761924Z","shell.execute_reply.started":"2022-03-07T08:57:39.761738Z","shell.execute_reply":"2022-03-07T08:57:39.761775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,usecols=[\"index_name\"])\ntable = pd.Categorical(d.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(7,3), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:57:39.76308Z","iopub.status.idle":"2022-03-07T08:57:39.763396Z","shell.execute_reply.started":"2022-03-07T08:57:39.763232Z","shell.execute_reply":"2022-03-07T08:57:39.763255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles = pd.read_csv(data_article_path,usecols= [\"article_id\",\"section_name\"])\narticles.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:36:36.493831Z","iopub.execute_input":"2022-03-07T11:36:36.494516Z","iopub.status.idle":"2022-03-07T11:36:36.845739Z","shell.execute_reply.started":"2022-03-07T11:36:36.494469Z","shell.execute_reply":"2022-03-07T11:36:36.844763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from nltk.stem import WordNetLemmatizer\nwordnet_lemmatizer = WordNetLemmatizer()\ndef text_preprocessing(text):\n    text = text.replace(\" & \",\"&\")\n    text = text.replace(\",\",\"\")\n    text = text.lower()\n    text = text.replace(\"womens\",\"women\")\n    text = text.replace(\"mans\",\"man\")\n    text = text.replace(\" other 2\",\"\")\n    text = text.strip()\n    words = text.split(\" \")\n    lemm_text = [wordnet_lemmatizer.lemmatize(word) for word in words]\n    return lemm_text\narticles['section_name_split']=articles['section_name'].apply(lambda x:text_preprocessing(x))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:46:40.113419Z","iopub.execute_input":"2022-03-07T11:46:40.114183Z","iopub.status.idle":"2022-03-07T11:46:41.65493Z","shell.execute_reply.started":"2022-03-07T11:46:40.114149Z","shell.execute_reply":"2022-03-07T11:46:41.653852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles['section_name_split'].head()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:46:42.280862Z","iopub.execute_input":"2022-03-07T11:46:42.281584Z","iopub.status.idle":"2022-03-07T11:46:42.289919Z","shell.execute_reply.started":"2022-03-07T11:46:42.281542Z","shell.execute_reply":"2022-03-07T11:46:42.288909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dd = articles['section_name_split'].values.tolist()\nunique_set = []\nfor d in dd :\n    unique_set.extend(d)\nelse :\n    keywords = list(np.unique(unique_set))\n    print(len(keywords))\n    print(keywords)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:47:24.327837Z","iopub.execute_input":"2022-03-07T11:47:24.328143Z","iopub.status.idle":"2022-03-07T11:47:24.512323Z","shell.execute_reply.started":"2022-03-07T11:47:24.328112Z","shell.execute_reply":"2022-03-07T11:47:24.511242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def find_keywords(keyword , x) :\n    return True if keyword in x else False\n## women cloth\n\ndef get_keyword_count(articles, keyword) :\n    sum_of_keyword = articles['section_name_split'].apply(lambda x : find_keywords(keyword, x)).sum()\n    return sum_of_keyword","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:54:42.004233Z","iopub.execute_input":"2022-03-07T11:54:42.004582Z","iopub.status.idle":"2022-03-07T11:54:42.011721Z","shell.execute_reply.started":"2022-03-07T11:54:42.004534Z","shell.execute_reply":"2022-03-07T11:54:42.010234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"keyword_count_table= {}\nfor keyword in keywords :\n    keyword_count_table[keyword]= get_keyword_count(articles, keyword)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:55:24.402245Z","iopub.execute_input":"2022-03-07T11:55:24.402545Z","iopub.status.idle":"2022-03-07T11:55:26.81863Z","shell.execute_reply.started":"2022-03-07T11:55:24.402513Z","shell.execute_reply":"2022-03-07T11:55:26.817644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"keyword_count_table= pd.Series(keyword_count_table).sort_values(ascending=False)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:56:42.228024Z","iopub.execute_input":"2022-03-07T11:56:42.228314Z","iopub.status.idle":"2022-03-07T11:56:42.234052Z","shell.execute_reply.started":"2022-03-07T11:56:42.228275Z","shell.execute_reply":"2022-03-07T11:56:42.233024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"keyword_count_table.plot.bar(figsize=(17,5))\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:56:58.730269Z","iopub.execute_input":"2022-03-07T11:56:58.730982Z","iopub.status.idle":"2022-03-07T11:56:59.632692Z","shell.execute_reply.started":"2022-03-07T11:56:58.730936Z","shell.execute_reply":"2022-03-07T11:56:59.631651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Transaction","metadata":{}},{"cell_type":"code","source":"data = pd.read_csv(data_transaction_path)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:06:58.131138Z","iopub.execute_input":"2022-03-07T13:06:58.131438Z","iopub.status.idle":"2022-03-07T13:07:37.557545Z","shell.execute_reply.started":"2022-03-07T13:06:58.131403Z","shell.execute_reply":"2022-03-07T13:07:37.556497Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Channels","metadata":{}},{"cell_type":"code","source":"data['sales_channel_id'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:07:37.559445Z","iopub.execute_input":"2022-03-07T13:07:37.55975Z","iopub.status.idle":"2022-03-07T13:07:37.731484Z","shell.execute_reply.started":"2022-03-07T13:07:37.559715Z","shell.execute_reply":"2022-03-07T13:07:37.730495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(np.log(data.query(\"sales_channel_id==1\")[\"price\"]),bins=60,color=\"b\",label=\"channel_id == 1\",alpha=0.3,density=True)\nplt.hist(np.log(data.query(\"sales_channel_id==2\")[\"price\"]),bins=60,color=\"r\",label=\"channel_id == 2\",alpha=0.3,density=True)\nplt.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:11.800495Z","iopub.execute_input":"2022-03-07T12:29:11.800814Z","iopub.status.idle":"2022-03-07T12:29:15.992686Z","shell.execute_reply.started":"2022-03-07T12:29:11.800779Z","shell.execute_reply":"2022-03-07T12:29:15.991611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Count Table Based on the Date(t_dat)","metadata":{}},{"cell_type":"code","source":"transaction_time = pd.to_datetime(data[\"t_dat\"])","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:32.716895Z","iopub.execute_input":"2022-03-07T12:29:32.71721Z","iopub.status.idle":"2022-03-07T12:29:37.827718Z","shell.execute_reply.started":"2022-03-07T12:29:32.717177Z","shell.execute_reply":"2022-03-07T12:29:37.826731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = pd.Categorical(transaction_time.dt.year.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(16,4), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:19.563013Z","iopub.execute_input":"2022-03-07T03:01:19.563311Z","iopub.status.idle":"2022-03-07T03:01:23.119444Z","shell.execute_reply.started":"2022-03-07T03:01:19.563281Z","shell.execute_reply":"2022-03-07T03:01:23.118482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = pd.Categorical(transaction_time.dt.month.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(16,4), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:23.12089Z","iopub.execute_input":"2022-03-07T03:01:23.121089Z","iopub.status.idle":"2022-03-07T03:01:26.678979Z","shell.execute_reply.started":"2022-03-07T03:01:23.121064Z","shell.execute_reply":"2022-03-07T03:01:26.677989Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[\"t_dat\"] = transaction_time","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:37.829455Z","iopub.execute_input":"2022-03-07T12:29:37.8297Z","iopub.status.idle":"2022-03-07T12:29:38.41169Z","shell.execute_reply.started":"2022-03-07T12:29:37.829668Z","shell.execute_reply":"2022-03-07T12:29:38.410714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.groupby(by=[data.t_dat.dt.month]).agg({\"price\" : [\"min\",\"max\",\"mean\",\"std\"]})","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:29.90889Z","iopub.execute_input":"2022-03-07T03:01:29.909342Z","iopub.status.idle":"2022-03-07T03:01:33.981926Z","shell.execute_reply.started":"2022-03-07T03:01:29.909296Z","shell.execute_reply":"2022-03-07T03:01:33.981022Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.groupby(by=[data.t_dat.dt.year , data.t_dat.dt.month]).agg({\"price\" : [\"min\",\"max\",\"mean\",\"std\"]})","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:33.983213Z","iopub.execute_input":"2022-03-07T03:01:33.983414Z","iopub.status.idle":"2022-03-07T03:01:42.078092Z","shell.execute_reply.started":"2022-03-07T03:01:33.983391Z","shell.execute_reply":"2022-03-07T03:01:42.077013Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = data.groupby(by=[data.t_dat.dt.year , data.t_dat.dt.month]).size()\ntable.index.names = [\"year\", \"month\"]","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:42.079318Z","iopub.execute_input":"2022-03-07T03:01:42.079659Z","iopub.status.idle":"2022-03-07T03:01:49.643917Z","shell.execute_reply.started":"2022-03-07T03:01:42.079622Z","shell.execute_reply":"2022-03-07T03:01:49.643023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = table.reset_index(drop=False).rename(columns={0:\"count\"})\ntable = table.sort_values(by=[\"year\",\"month\"])\ntable[\"year/month\"] = table.apply(lambda x : f'{x[\"year\"]:04d}/{x[\"month\"]:02d}',axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:49.646017Z","iopub.execute_input":"2022-03-07T03:01:49.646326Z","iopub.status.idle":"2022-03-07T03:01:49.66096Z","shell.execute_reply.started":"2022-03-07T03:01:49.646285Z","shell.execute_reply":"2022-03-07T03:01:49.659771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table.plot(x = \"year/month\",y=\"count\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:49.661993Z","iopub.execute_input":"2022-03-07T03:01:49.662198Z","iopub.status.idle":"2022-03-07T03:01:49.829679Z","shell.execute_reply.started":"2022-03-07T03:01:49.662173Z","shell.execute_reply":"2022-03-07T03:01:49.828932Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.treemap(table, path=['year', 'month'], values='count')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:49.830821Z","iopub.execute_input":"2022-03-07T03:01:49.831148Z","iopub.status.idle":"2022-03-07T03:01:51.061497Z","shell.execute_reply.started":"2022-03-07T03:01:49.83112Z","shell.execute_reply":"2022-03-07T03:01:51.060583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = data.groupby(by=[data.t_dat.dt.dayofweek]).size()\ntable.index.names = [\"dayofweek\"]\ntable","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:13:22.567665Z","iopub.execute_input":"2022-03-07T03:13:22.568308Z","iopub.status.idle":"2022-03-07T03:13:26.368363Z","shell.execute_reply.started":"2022-03-07T03:13:22.568254Z","shell.execute_reply":"2022-03-07T03:13:26.367388Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(5,5))\ncolors = sns.color_palette('Paired')\nax.pie(table, \n       labels=['Mon','Tue',\"Wed\",\"Thr\",\"Fri\",\"Sat\",\"Sun\"],\n       autopct='%1.1f%%',shadow=True, startangle=90, colors=colors)\nax.axis('equal')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:13:27.041815Z","iopub.execute_input":"2022-03-07T03:13:27.042091Z","iopub.status.idle":"2022-03-07T03:13:27.216763Z","shell.execute_reply.started":"2022-03-07T03:13:27.04206Z","shell.execute_reply":"2022-03-07T03:13:27.215542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = table.reset_index(drop=False)\ntable[\"isholiday\"] = ['Weekdays','Weekdays','Weekdays','Weekdays','Weekdays','Holidays','Holidays']\ntable = table.groupby('isholiday').agg({0:\"sum\"})\ntable","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:13:29.54607Z","iopub.execute_input":"2022-03-07T03:13:29.546829Z","iopub.status.idle":"2022-03-07T03:13:29.562039Z","shell.execute_reply.started":"2022-03-07T03:13:29.546782Z","shell.execute_reply":"2022-03-07T03:13:29.561099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = pd.Series(table.values.squeeze(),index = table.index.values)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:43:58.063767Z","iopub.execute_input":"2022-03-07T03:43:58.064864Z","iopub.status.idle":"2022-03-07T03:43:58.070458Z","shell.execute_reply.started":"2022-03-07T03:43:58.064807Z","shell.execute_reply":"2022-03-07T03:43:58.069727Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:44:15.163166Z","iopub.execute_input":"2022-03-07T03:44:15.163462Z","iopub.status.idle":"2022-03-07T03:44:15.169036Z","shell.execute_reply.started":"2022-03-07T03:44:15.163431Z","shell.execute_reply":"2022-03-07T03:44:15.168234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(5,5))\ncolors = sns.color_palette('Paired')\nax.pie(table, \n       labels=['Holidays',\"Weekdays\"],\n       autopct='%1.1f%%',shadow=True, startangle=90, colors=colors)\nax.axis('equal')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:44:28.887392Z","iopub.execute_input":"2022-03-07T03:44:28.887699Z","iopub.status.idle":"2022-03-07T03:44:28.999938Z","shell.execute_reply.started":"2022-03-07T03:44:28.887654Z","shell.execute_reply":"2022-03-07T03:44:28.998734Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles = pd.read_csv(data_article_path)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:19.653585Z","iopub.execute_input":"2022-03-07T12:29:19.653921Z","iopub.status.idle":"2022-03-07T12:29:20.361763Z","shell.execute_reply.started":"2022-03-07T12:29:19.653877Z","shell.execute_reply":"2022-03-07T12:29:20.360594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top3_year_article_table = data.groupby([data.t_dat.dt.year]).apply(lambda x : x['article_id'].value_counts().head(3))\ntop3_year_article_table","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:38.413529Z","iopub.execute_input":"2022-03-07T12:29:38.413982Z","iopub.status.idle":"2022-03-07T12:29:48.1187Z","shell.execute_reply.started":"2022-03-07T12:29:38.413945Z","shell.execute_reply":"2022-03-07T12:29:48.11763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = list(top3_year_article_table.reset_index()['level_1'].unique())\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 5 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:48.122011Z","iopub.execute_input":"2022-03-07T12:29:48.12263Z","iopub.status.idle":"2022-03-07T12:29:50.956184Z","shell.execute_reply.started":"2022-03-07T12:29:48.122578Z","shell.execute_reply":"2022-03-07T12:29:50.955431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top3_month_article_table =  data.groupby([data.t_dat.dt.month]).apply(lambda x : x['article_id'].value_counts().head(3))\ntop3_month_article_table","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:52.716336Z","iopub.execute_input":"2022-03-07T12:29:52.717152Z","iopub.status.idle":"2022-03-07T12:30:00.485229Z","shell.execute_reply.started":"2022-03-07T12:29:52.717118Z","shell.execute_reply":"2022-03-07T12:30:00.484213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = list(top3_month_article_table.reset_index()['level_1'].unique())\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 7 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:59:10.948298Z","iopub.execute_input":"2022-03-07T03:59:10.948594Z","iopub.status.idle":"2022-03-07T03:59:16.710419Z","shell.execute_reply.started":"2022-03-07T03:59:10.948559Z","shell.execute_reply":"2022-03-07T03:59:16.709153Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top3_dayofweek_article_table= data.groupby([data.t_dat.dt.dayofweek]).apply(lambda x : x['article_id'].value_counts().head(3))\ntop3_dayofweek_article_table","metadata":{"execution":{"iopub.status.busy":"2022-03-07T04:00:01.932621Z","iopub.execute_input":"2022-03-07T04:00:01.933599Z","iopub.status.idle":"2022-03-07T04:00:09.336898Z","shell.execute_reply.started":"2022-03-07T04:00:01.933549Z","shell.execute_reply":"2022-03-07T04:00:09.335957Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = list(top3_dayofweek_article_table.reset_index()['level_1'].unique())\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 3 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T04:00:27.530769Z","iopub.execute_input":"2022-03-07T04:00:27.531052Z","iopub.status.idle":"2022-03-07T04:00:28.960619Z","shell.execute_reply.started":"2022-03-07T04:00:27.531025Z","shell.execute_reply":"2022-03-07T04:00:28.959805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_count_table= data.article_id.value_counts()\ntop10 = article_count_table.head(10)\ntop10_articles = top10.index.values.tolist()\n","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:49:05.036184Z","iopub.execute_input":"2022-03-07T03:49:05.036498Z","iopub.status.idle":"2022-03-07T03:49:06.784064Z","shell.execute_reply.started":"2022-03-07T03:49:05.036465Z","shell.execute_reply":"2022-03-07T03:49:06.783218Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"visualize_articles(articles,top10_articles , n_total = len(top10_articles) , n_cols = 5 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:55:45.493282Z","iopub.execute_input":"2022-03-07T03:55:45.494047Z","iopub.status.idle":"2022-03-07T03:55:48.786522Z","shell.execute_reply.started":"2022-03-07T03:55:45.493998Z","shell.execute_reply":"2022-03-07T03:55:48.785762Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = data.groupby(by=[data.t_dat.dt.year , data.t_dat.dt.dayofweek]).agg({\"price\" : [\"mean\"]})\ntable.index.names = [\"year\",\"dayofweek\"]","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:51.062845Z","iopub.execute_input":"2022-03-07T03:01:51.063609Z","iopub.status.idle":"2022-03-07T03:02:01.592588Z","shell.execute_reply.started":"2022-03-07T03:01:51.063569Z","shell.execute_reply":"2022-03-07T03:02:01.59137Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = table.reset_index().droplevel(1,axis=1)\nfig = px.treemap(table, path=['year', 'dayofweek'], values='price')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:02:01.594558Z","iopub.execute_input":"2022-03-07T03:02:01.594897Z","iopub.status.idle":"2022-03-07T03:02:01.693332Z","shell.execute_reply.started":"2022-03-07T03:02:01.59486Z","shell.execute_reply":"2022-03-07T03:02:01.692472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer_purchage_freq = data.groupby([data.customer_id]).size()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:52:32.114246Z","iopub.execute_input":"2022-03-06T03:52:32.114504Z","iopub.status.idle":"2022-03-06T03:52:44.997698Z","shell.execute_reply.started":"2022-03-06T03:52:32.114476Z","shell.execute_reply":"2022-03-06T03:52:44.996781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer_purchage_freq_greather_than_1000 = customer_purchage_freq[customer_purchage_freq > 1000]","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:56:47.751671Z","iopub.execute_input":"2022-03-06T03:56:47.75197Z","iopub.status.idle":"2022-03-06T03:56:47.759091Z","shell.execute_reply.started":"2022-03-06T03:56:47.75194Z","shell.execute_reply":"2022-03-06T03:56:47.757714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer_purchage_freq_greather_than_1000","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:56:48.821082Z","iopub.execute_input":"2022-03-06T03:56:48.821312Z","iopub.status.idle":"2022-03-06T03:56:48.826931Z","shell.execute_reply.started":"2022-03-06T03:56:48.82129Z","shell.execute_reply":"2022-03-06T03:56:48.826212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n_of_customer = data.customer_id.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:56:52.669705Z","iopub.execute_input":"2022-03-06T03:56:52.669974Z","iopub.status.idle":"2022-03-06T03:57:00.346466Z","shell.execute_reply.started":"2022-03-06T03:56:52.669919Z","shell.execute_reply":"2022-03-06T03:57:00.345472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f\"{len(customer_purchage_freq_greather_than_1000)}/{n_of_customer}\"","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:58:02.134694Z","iopub.execute_input":"2022-03-06T03:58:02.134963Z","iopub.status.idle":"2022-03-06T03:58:02.140095Z","shell.execute_reply.started":"2022-03-06T03:58:02.134935Z","shell.execute_reply":"2022-03-06T03:58:02.139435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer_list =customer_purchage_freq_greather_than_1000.index.tolist()\nsub_data = data.query(\"customer_id in @customer_list\")","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:58:59.841103Z","iopub.execute_input":"2022-03-06T03:58:59.841389Z","iopub.status.idle":"2022-03-06T03:59:02.977275Z","shell.execute_reply.started":"2022-03-06T03:58:59.841358Z","shell.execute_reply":"2022-03-06T03:59:02.976432Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_data.groupby(\"customer_id\")[\"price\"].describe()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:59:31.435062Z","iopub.execute_input":"2022-03-06T03:59:31.43535Z","iopub.status.idle":"2022-03-06T03:59:31.490679Z","shell.execute_reply.started":"2022-03-06T03:59:31.435321Z","shell.execute_reply":"2022-03-06T03:59:31.489796Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = sub_data['article_id'].value_counts()\npd.DataFrame(article_list[article_list > 7]).T","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:00:51.85286Z","iopub.execute_input":"2022-03-06T04:00:51.853143Z","iopub.status.idle":"2022-03-06T04:00:51.876765Z","shell.execute_reply.started":"2022-03-06T04:00:51.853111Z","shell.execute_reply":"2022-03-06T04:00:51.875979Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_data.groupby([\"article_id\",\"customer_id\"]).size()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:01:29.763729Z","iopub.execute_input":"2022-03-06T04:01:29.764178Z","iopub.status.idle":"2022-03-06T04:01:29.78389Z","shell.execute_reply.started":"2022-03-06T04:01:29.764143Z","shell.execute_reply":"2022-03-06T04:01:29.783237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"regular_customer_articles_10 = sub_data.groupby([\"article_id\"]).agg({\"customer_id\" : [\"count\"]}).reset_index(drop=False).droplevel(1 ,axis=1).query(\"customer_id > 10\")","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:04:17.614695Z","iopub.execute_input":"2022-03-06T04:04:17.615897Z","iopub.status.idle":"2022-03-06T04:04:17.636056Z","shell.execute_reply.started":"2022-03-06T04:04:17.615827Z","shell.execute_reply":"2022-03-06T04:04:17.635432Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = regular_customer_articles_10.article_id.values.tolist()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:04:34.243399Z","iopub.execute_input":"2022-03-06T04:04:34.24374Z","iopub.status.idle":"2022-03-06T04:04:34.248219Z","shell.execute_reply.started":"2022-03-06T04:04:34.243711Z","shell.execute_reply":"2022-03-06T04:04:34.247507Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:05:20.179059Z","iopub.execute_input":"2022-03-06T04:05:20.179862Z","iopub.status.idle":"2022-03-06T04:05:20.184912Z","shell.execute_reply.started":"2022-03-06T04:05:20.17983Z","shell.execute_reply":"2022-03-06T04:05:20.184342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_data.query(\"article_id in @article_list\").groupby([\"article_id\",\"customer_id\"]).size()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:04:56.657865Z","iopub.execute_input":"2022-03-06T04:04:56.658767Z","iopub.status.idle":"2022-03-06T04:04:56.673755Z","shell.execute_reply.started":"2022-03-06T04:04:56.658704Z","shell.execute_reply":"2022-03-06T04:04:56.673246Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles = pd.read_csv(data_article_path)","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:06:25.922391Z","iopub.execute_input":"2022-03-06T04:06:25.923191Z","iopub.status.idle":"2022-03-06T04:06:26.865082Z","shell.execute_reply.started":"2022-03-06T04:06:25.923127Z","shell.execute_reply":"2022-03-06T04:06:26.864262Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n## reference : https://www.kaggle.com/vanguarde/h-m-eda-first-look \nf, ax = plt.subplots(1, 6, figsize=(25,10))\naxes = ax.flatten()\ni = 0\nfor article in article_list:\n    desc = articles[articles['article_id'] == article]['detail_desc'].iloc[0]\n    desc_list = desc.split(' ')\n    for j, elem in enumerate(desc_list):\n        if j > 0 and j % 5 == 0:\n            desc_list[j] = desc_list[j] + '\\n'\n    desc = ' '.join(desc_list)\n    img = mpimg.imread(f'../input/h-and-m-personalized-fashion-recommendations/images/0{str(article)[:2]}/0{int(article)}.jpg')\n    axes[i].imshow(img)\n    axes[i].set_xticks([], [])\n    axes[i].set_yticks([], [])\n    axes[i].set_title(article)\n    axes[i].grid(False)\n    axes[i].set_xlabel(desc, fontsize=10)\n    i += 1\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:10:10.977726Z","iopub.execute_input":"2022-03-06T04:10:10.977983Z","iopub.status.idle":"2022-03-06T04:10:13.034242Z","shell.execute_reply.started":"2022-03-06T04:10:10.977957Z","shell.execute_reply":"2022-03-06T04:10:13.033499Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Special Customer (old age)\n\n\nAccording to the customer age information, it can be confirmed that older people also make purchases.\n\n* H&M targets woman in the lower middle class and working class, The target market for H&M is for younger people.\n\n[reference](https://ukdiss.com/examples/marketing-analysis-h-and-m.php)\n\nAlthough the company is targeting younger people, it wanted to identify products that would attract older people to buy as well.\n\nAt first, I thought it was an error in the data, but after actually analyzing it, I found that I was buying products with an older age group.\n\n**Let's analyze these customers!**\n","metadata":{}},{"cell_type":"code","source":"specal_customer_transaction_data = data.query(\"customer_id in @special_customer_list\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:33:58.191492Z","iopub.execute_input":"2022-03-07T13:33:58.191782Z","iopub.status.idle":"2022-03-07T13:34:04.383015Z","shell.execute_reply.started":"2022-03-07T13:33:58.191752Z","shell.execute_reply":"2022-03-07T13:34:04.381992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data = pd.merge(specal_customer_transaction_data , customer_binned , how=\"left\",on=\"customer_id\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:04.384614Z","iopub.execute_input":"2022-03-07T13:34:04.384867Z","iopub.status.idle":"2022-03-07T13:34:05.071564Z","shell.execute_reply.started":"2022-03-07T13:34:04.384836Z","shell.execute_reply":"2022-03-07T13:34:05.070763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data.shape","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:05.072926Z","iopub.execute_input":"2022-03-07T13:34:05.073497Z","iopub.status.idle":"2022-03-07T13:34:05.079854Z","shell.execute_reply.started":"2022-03-07T13:34:05.073453Z","shell.execute_reply":"2022-03-07T13:34:05.078996Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:05.081737Z","iopub.execute_input":"2022-03-07T13:34:05.081992Z","iopub.status.idle":"2022-03-07T13:34:05.102376Z","shell.execute_reply.started":"2022-03-07T13:34:05.081945Z","shell.execute_reply":"2022-03-07T13:34:05.101485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles = pd.read_csv(data_article_path)\nspecal_customer_transaction_data = pd.merge(specal_customer_transaction_data , articles , how=\"left\",on=\"article_id\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:05.104084Z","iopub.execute_input":"2022-03-07T13:34:05.104398Z","iopub.status.idle":"2022-03-07T13:34:06.022585Z","shell.execute_reply.started":"2022-03-07T13:34:05.104354Z","shell.execute_reply":"2022-03-07T13:34:06.021662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data['garment_group_name'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:06.023736Z","iopub.execute_input":"2022-03-07T13:34:06.023966Z","iopub.status.idle":"2022-03-07T13:34:06.034785Z","shell.execute_reply.started":"2022-03-07T13:34:06.023937Z","shell.execute_reply":"2022-03-07T13:34:06.034028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data['section_name'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:08.982052Z","iopub.execute_input":"2022-03-07T13:34:08.982306Z","iopub.status.idle":"2022-03-07T13:34:08.994778Z","shell.execute_reply.started":"2022-03-07T13:34:08.982277Z","shell.execute_reply":"2022-03-07T13:34:08.993909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data['sales_channel_id'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:09.699849Z","iopub.execute_input":"2022-03-07T13:34:09.7008Z","iopub.status.idle":"2022-03-07T13:34:09.708819Z","shell.execute_reply.started":"2022-03-07T13:34:09.70075Z","shell.execute_reply":"2022-03-07T13:34:09.707667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data['club_member_status'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:10.416648Z","iopub.execute_input":"2022-03-07T13:34:10.416934Z","iopub.status.idle":"2022-03-07T13:34:10.429028Z","shell.execute_reply.started":"2022-03-07T13:34:10.416904Z","shell.execute_reply":"2022-03-07T13:34:10.428202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data['index_group_name'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:11.202867Z","iopub.execute_input":"2022-03-07T13:34:11.203706Z","iopub.status.idle":"2022-03-07T13:34:11.217863Z","shell.execute_reply.started":"2022-03-07T13:34:11.203632Z","shell.execute_reply":"2022-03-07T13:34:11.217158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## reference : https://www.kaggle.com/junjitakeshima/h-m-easy-grouping-by-sex-attribute-age-en-jp\nspecal_customer_transaction_data_by_sex = specal_customer_transaction_data[[\"customer_id\",\"index_group_name\",\"article_id\"]].groupby([\"customer_id\",\"index_group_name\"]).count().unstack()\nspecal_customer_transaction_data_by_sex = specal_customer_transaction_data_by_sex.fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:13.088076Z","iopub.execute_input":"2022-03-07T13:34:13.088769Z","iopub.status.idle":"2022-03-07T13:34:13.11933Z","shell.execute_reply.started":"2022-03-07T13:34:13.088723Z","shell.execute_reply":"2022-03-07T13:34:13.118378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data_by_sex[\"attribute\"] =specal_customer_transaction_data_by_sex.apply(lambda x : list(x[x == x.max()].index)[0][1], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:14.199891Z","iopub.execute_input":"2022-03-07T13:34:14.200449Z","iopub.status.idle":"2022-03-07T13:34:14.785194Z","shell.execute_reply.started":"2022-03-07T13:34:14.200411Z","shell.execute_reply":"2022-03-07T13:34:14.784411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data_by_sex_selected = specal_customer_transaction_data_by_sex.reset_index(drop=False)[[\"customer_id\",\"attribute\"]]","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:16.482607Z","iopub.execute_input":"2022-03-07T13:34:16.483122Z","iopub.status.idle":"2022-03-07T13:34:16.494386Z","shell.execute_reply.started":"2022-03-07T13:34:16.483077Z","shell.execute_reply":"2022-03-07T13:34:16.493555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data = pd.merge(specal_customer_transaction_data,specal_customer_transaction_data_by_sex_selected.droplevel(1,axis=1) , how=\"left\",on=\"customer_id\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:17.291373Z","iopub.execute_input":"2022-03-07T13:34:17.292221Z","iopub.status.idle":"2022-03-07T13:34:17.380797Z","shell.execute_reply.started":"2022-03-07T13:34:17.292176Z","shell.execute_reply":"2022-03-07T13:34:17.379894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data[[\"customer_id\",\"article_id\",\"attribute\"]].head()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:37:44.193921Z","iopub.execute_input":"2022-03-07T13:37:44.194507Z","iopub.status.idle":"2022-03-07T13:37:44.20809Z","shell.execute_reply.started":"2022-03-07T13:37:44.19447Z","shell.execute_reply":"2022-03-07T13:37:44.207044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data[\"attribute\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:27.774838Z","iopub.execute_input":"2022-03-07T13:34:27.775144Z","iopub.status.idle":"2022-03-07T13:34:27.785353Z","shell.execute_reply.started":"2022-03-07T13:34:27.775113Z","shell.execute_reply":"2022-03-07T13:34:27.784453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = specal_customer_transaction_data.query('attribute == \"Menswear\"').article_id.value_counts().head(6).index.tolist()\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 6 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:36:31.671375Z","iopub.execute_input":"2022-03-07T13:36:31.671668Z","iopub.status.idle":"2022-03-07T13:36:33.746111Z","shell.execute_reply.started":"2022-03-07T13:36:31.671638Z","shell.execute_reply":"2022-03-07T13:36:33.745179Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = specal_customer_transaction_data.query('attribute == \"Ladieswear\"').article_id.value_counts().head(6).index.tolist()\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 6 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:37:18.510821Z","iopub.execute_input":"2022-03-07T13:37:18.511115Z","iopub.status.idle":"2022-03-07T13:37:20.270278Z","shell.execute_reply.started":"2022-03-07T13:37:18.511077Z","shell.execute_reply":"2022-03-07T13:37:20.269371Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = specal_customer_transaction_data.query('attribute == \"Divided\"').article_id.value_counts().head(6).index.tolist()\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 6 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:37:29.894286Z","iopub.execute_input":"2022-03-07T13:37:29.894601Z","iopub.status.idle":"2022-03-07T13:37:32.121389Z","shell.execute_reply.started":"2022-03-07T13:37:29.894564Z","shell.execute_reply":"2022-03-07T13:37:32.12036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = specal_customer_transaction_data.query('attribute == \"Sport\"').article_id.value_counts().head(6).index.tolist()\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 6 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:38:28.42716Z","iopub.execute_input":"2022-03-07T13:38:28.428052Z","iopub.status.idle":"2022-03-07T13:38:30.575701Z","shell.execute_reply.started":"2022-03-07T13:38:28.427992Z","shell.execute_reply":"2022-03-07T13:38:30.574741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"acc_article_list = specal_customer_transaction_data[specal_customer_transaction_data['index_name'].str.contains(\"Accessories\")].article_id.value_counts().head(6).index.tolist()\nvisualize_articles(articles,acc_article_list , n_total = len(acc_article_list) , n_cols = 6 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:41:57.225767Z","iopub.execute_input":"2022-03-07T13:41:57.226076Z","iopub.status.idle":"2022-03-07T13:41:59.19048Z","shell.execute_reply.started":"2022-03-07T13:41:57.226042Z","shell.execute_reply":"2022-03-07T13:41:59.189628Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Some users probably bought clothes for their grandchildren.","metadata":{}},{"cell_type":"code","source":"specal_customer_transaction_data_certain_garment = specal_customer_transaction_data.query('garment_group_name == \"Woven/Jersey/Knitted mix Baby\"')[[\"article_id\",\"age_binned\"]]\narticle_list = specal_customer_transaction_data_certain_garment['article_id'].unique().tolist()\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 5 , figsize=(25,20))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:43:00.760107Z","iopub.execute_input":"2022-03-07T13:43:00.760395Z","iopub.status.idle":"2022-03-07T13:43:06.159824Z","shell.execute_reply.started":"2022-03-07T13:43:00.760364Z","shell.execute_reply":"2022-03-07T13:43:06.159077Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data_top_6 = specal_customer_transaction_data.groupby(\"age_binned\").apply(lambda x : x['article_id'].value_counts().head(6))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:36:47.278695Z","iopub.execute_input":"2022-03-07T13:36:47.278993Z","iopub.status.idle":"2022-03-07T13:36:47.300703Z","shell.execute_reply.started":"2022-03-07T13:36:47.278943Z","shell.execute_reply":"2022-03-07T13:36:47.300045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data_top_6 = specal_customer_transaction_data_top_6.reset_index(drop=False)\nspecal_customer_transaction_data_top_6","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:36:47.301905Z","iopub.execute_input":"2022-03-07T13:36:47.302619Z","iopub.status.idle":"2022-03-07T13:36:47.315966Z","shell.execute_reply.started":"2022-03-07T13:36:47.302579Z","shell.execute_reply":"2022-03-07T13:36:47.315048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f, ax = plt.subplots(2, 6, figsize=(25,15))\naxes = ax.flatten()\n\ni = 0\narticle_list = specal_customer_transaction_data_top_6.head(6)['level_1'].values.tolist()\nfor article in article_list:\n    visualize_article(axes , i , articles , article)\n    i += 1\narticle_list = specal_customer_transaction_data_top_6.tail(6)['level_1'].values.tolist()\nfor article in article_list:\n    visualize_article(axes , i , articles , article)\n    i += 1\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:40:31.955015Z","iopub.execute_input":"2022-03-07T12:40:31.95532Z","iopub.status.idle":"2022-03-07T12:40:35.653772Z","shell.execute_reply.started":"2022-03-07T12:40:31.955288Z","shell.execute_reply":"2022-03-07T12:40:35.652801Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}