{"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":"## **<span style=\"color:#023e8a;\">Intro</span>**\n\n**<span style=\"color:#023e8a;\">The competition is dedicated to the product recomendations (H&M)  </span>**\n\n**<span style=\"color:#023e8a;\">Here we have different kinds of data that help us to get good recomendations: </span>**\n\n📸 `images` - images of every article_id\n\n🙋 `articles`  - detailed metadata of every article_id\n\n👔 `customers`  - detailed metadata of every customer_id\n\n🧾 `transactions_train`  - purchases with details","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nfrom matplotlib import pyplot as plt\nfrom tqdm.notebook import tqdm","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:47:56.670234Z","iopub.execute_input":"2022-02-27T20:47:56.670548Z","iopub.status.idle":"2022-02-27T20:47:56.675784Z","shell.execute_reply.started":"2022-02-27T20:47:56.670518Z","shell.execute_reply":"2022-02-27T20:47:56.674788Z"},"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-02-27T20:47:56.677698Z","iopub.execute_input":"2022-02-27T20:47:56.677938Z","iopub.status.idle":"2022-02-27T20:49:07.899226Z","shell.execute_reply.started":"2022-02-27T20:47:56.677911Z","shell.execute_reply":"2022-02-27T20:49:07.898331Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## **<span id=\"Articles\" style=\"color:#023e8a;\">2. Articles</span>**","metadata":{}},{"cell_type":"markdown","source":"**<span style=\"color:#023e8a;\"> This table contains all h&m articles with details such as a type of product, a color, a product group and other features.</span>**  \n**<span style=\"color:#023e8a;\"> Article data description: </span>**\n\n> `article_id` **<span style=\"color:#023e8a;\">: A unique identifier of every article.</span>**  \n> `product_code`, `prod_name` **<span style=\"color:#023e8a;\">: A unique identifier of every product and its name (not the same).</span>**  \n> `product_type`, `product_type_name` **<span style=\"color:#023e8a;\">: The group of product_code and its name</span>**  \n> `graphical_appearance_no`, `graphical_appearance_name` **<span style=\"color:#023e8a;\">: The group of graphics and its name</span>**  \n> `colour_group_code`, `colour_group_name` **<span style=\"color:#023e8a;\">: The group of color and its name</span>**  \n> `graphical_appearance_no`, `graphical_appearance_name` **<span style=\"color:#023e8a;\">: The group of graphics and its name</span>**  \n> `perceived_colour_value_id`, `perceived_colour_value_name`, `perceived_colour_master_id`, `perceived_colour_master_name` **<span style=\"color:#023e8a;\">: The added color info</span>**  \n> `department_no`, `department_name`: **<span style=\"color:#023e8a;\">: A unique identifier of every dep and its name</span>**  \n> `index_code`, `index_name`: **<span style=\"color:#023e8a;\">: A unique identifier of every index and its name</span>**  \n> `index_group_no`, `index_group_name`: **<span style=\"color:#023e8a;\">: A group of indeces and its name</span>**  \n> `section_no`, `section_name`: **<span style=\"color:#023e8a;\">: A unique identifier of every section and its name</span>**  \n> `garment_group_no`, `garment_group_name`: **<span style=\"color:#023e8a;\">: A unique identifier of every garment and its name</span>**  \n> `detail_desc`: **<span style=\"color:#023e8a;\">: Details</span>**  ","metadata":{}},{"cell_type":"code","source":"articles.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:07.900719Z","iopub.execute_input":"2022-02-27T20:49:07.901041Z","iopub.status.idle":"2022-02-27T20:49:07.933669Z","shell.execute_reply.started":"2022-02-27T20:49:07.900999Z","shell.execute_reply":"2022-02-27T20:49:07.932480Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(articles)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:07.944124Z","iopub.execute_input":"2022-02-27T20:49:07.944729Z","iopub.status.idle":"2022-02-27T20:49:07.951610Z","shell.execute_reply.started":"2022-02-27T20:49:07.944674Z","shell.execute_reply":"2022-02-27T20:49:07.950974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def quick_dups(column_name, table=articles):\n    dups = {}\n    duplicates = 0\n    for single in table[column_name]:\n        if single not in dups:\n            dups[single] = 0\n\n        dups[single] += 1\n        duplicates += 1\n\n    dups1 = []\n    dups2 = []\n    for key in dups.keys():\n        dups1.append(dups[key])\n        dups2.append(key)\n        \n    print(duplicates, np.min(dups1), np.max(dups1), np.mean(dups1), np.median(dups1))\n    \n    ind = np.argsort(dups1)\n\n    dups1 = np.flip(np.array(dups1)[ind])\n    dups2 = np.flip(np.array(dups2)[ind])\n    \n    print(dups1[0:10])\n    print(dups2[0:10])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:07.952784Z","iopub.execute_input":"2022-02-27T20:49:07.953416Z","iopub.status.idle":"2022-02-27T20:49:07.961845Z","shell.execute_reply.started":"2022-02-27T20:49:07.953382Z","shell.execute_reply":"2022-02-27T20:49:07.961319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_dups('product_code')","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:07.962706Z","iopub.execute_input":"2022-02-27T20:49:07.963438Z","iopub.status.idle":"2022-02-27T20:49:08.047398Z","shell.execute_reply.started":"2022-02-27T20:49:07.963405Z","shell.execute_reply":"2022-02-27T20:49:08.046574Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def quick_bar_chart(\n    column_name, figsize, subset=None, table=articles, debug=False,\n    labelAxisX='TODO', labelAxisY='TODO', labelTitle='TODO', save=None):\n    \n    data = {}\n    for single in table[column_name]:\n        if single not in data:\n            data[single] = 0\n        data[single] += 1\n        \n    if debug:\n        print(data)\n\n    dataArrKey = []\n    dataArrCount = []\n    for key in data.keys():\n        dataArrKey.append(key)\n        dataArrCount.append(data[key])\n\n    if debug:\n        print(dataArrKey)\n\n    ind = np.argsort(dataArrCount)\n\n    dataArrCountFlip = np.flip(np.array(dataArrCount)[ind])\n    dataArrKeyFlip = np.flip(np.array(dataArrKey)[ind])\n    \n    if debug:\n        print(dataArrKeyFlip)\n    \n    fig = plt.figure(figsize=figsize, dpi=80)\n    ax = fig.add_axes([0,0,1,1])\n    if subset != None:\n        ax.bar(dataArrKeyFlip[0:subset],dataArrCountFlip[0:subset], facecolor='#CC071E')\n    else:\n        ax.bar(dataArrKeyFlip,dataArrCountFlip, facecolor='#CC071E')\n    fig.align_labels()\n    plt.xlabel(labelAxisX)\n    plt.ylabel(labelAxisY)\n    plt.title(labelTitle)\n    \n    if save != None:\n        plt.savefig(save, dpi=80)\n    plt.xticks(rotation=45, ha='right', rotation_mode='anchor')\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:03:36.284359Z","iopub.execute_input":"2022-02-27T21:03:36.284623Z","iopub.status.idle":"2022-02-27T21:03:36.294583Z","shell.execute_reply.started":"2022-02-27T21:03:36.284595Z","shell.execute_reply":"2022-02-27T21:03:36.293980Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#prod_name, detail_desc\n#quick_bar_chart('product_type_name', (15, 3))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:08.060316Z","iopub.execute_input":"2022-02-27T20:49:08.060976Z","iopub.status.idle":"2022-02-27T20:49:08.071536Z","shell.execute_reply.started":"2022-02-27T20:49:08.060937Z","shell.execute_reply":"2022-02-27T20:49:08.070825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('garment_group_name', (10, 3))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:08.073552Z","iopub.execute_input":"2022-02-27T20:49:08.073908Z","iopub.status.idle":"2022-02-27T20:49:08.384846Z","shell.execute_reply.started":"2022-02-27T20:49:08.073874Z","shell.execute_reply":"2022-02-27T20:49:08.384138Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('department_name', (15, 3), True)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:08.385917Z","iopub.execute_input":"2022-02-27T20:49:08.386766Z","iopub.status.idle":"2022-02-27T20:49:09.183104Z","shell.execute_reply.started":"2022-02-27T20:49:08.386726Z","shell.execute_reply":"2022-02-27T20:49:09.182079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('graphical_appearance_name', (5, 3), subset=20, labelAxisX='Pattern', labelAxisY='Count', labelTitle='Count of Different Patterns')","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:07:28.512080Z","iopub.execute_input":"2022-02-27T21:07:28.512350Z","iopub.status.idle":"2022-02-27T21:07:28.789431Z","shell.execute_reply.started":"2022-02-27T21:07:28.512323Z","shell.execute_reply":"2022-02-27T21:07:28.788618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('product_group_name', (5, 3))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:09.526771Z","iopub.execute_input":"2022-02-27T20:49:09.527774Z","iopub.status.idle":"2022-02-27T20:49:09.821698Z","shell.execute_reply.started":"2022-02-27T20:49:09.527726Z","shell.execute_reply":"2022-02-27T20:49:09.820832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('colour_group_name', (5, 3),\n                labelAxisX='Color',\n                labelAxisY='Count',\n                labelTitle='Count of different Colors of Clothing',\n                save='color-count.png',\n                subset=20)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:04:44.619553Z","iopub.execute_input":"2022-02-27T21:04:44.620002Z","iopub.status.idle":"2022-02-27T21:04:44.978388Z","shell.execute_reply.started":"2022-02-27T21:04:44.619970Z","shell.execute_reply":"2022-02-27T21:04:44.977791Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('index_group_name', (3, 3), labelAxisX='Group', labelAxisY='Count', labelTitle='Count of Products over Groups')","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:16:15.018830Z","iopub.execute_input":"2022-02-27T21:16:15.019108Z","iopub.status.idle":"2022-02-27T21:16:15.217078Z","shell.execute_reply.started":"2022-02-27T21:16:15.019077Z","shell.execute_reply":"2022-02-27T21:16:15.216332Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('index_group_name', (3, 3)) # same as above, redundant column","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:10.792195Z","iopub.execute_input":"2022-02-27T20:49:10.792489Z","iopub.status.idle":"2022-02-27T20:49:10.994569Z","shell.execute_reply.started":"2022-02-27T20:49:10.792453Z","shell.execute_reply":"2022-02-27T20:49:10.993609Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('section_name', (15, 3))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:10.995996Z","iopub.execute_input":"2022-02-27T20:49:10.996293Z","iopub.status.idle":"2022-02-27T20:49:12.290884Z","shell.execute_reply.started":"2022-02-27T20:49:10.996245Z","shell.execute_reply":"2022-02-27T20:49:12.290003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**<span style=\"color:#023e8a;\"> Customers data description: </span>**\n\n> `customer_id` **<span style=\"color:#023e8a;\">: A unique identifier of every customer</span>**  \n> `FN` **<span style=\"color:#023e8a;\">: 1 or missed </span>**  \n> `Active` **<span style=\"color:#023e8a;\">: 1 or missed</span>**  \n> `club_member_status` **<span style=\"color:#023e8a;\">: Status in club</span>**  \n> `fashion_news_frequency` **<span style=\"color:#023e8a;\">: How often H&M may send news to customer</span>**  \n> `age` **<span style=\"color:#023e8a;\">: The current age</span>**  \n> `postal_code` **<span style=\"color:#023e8a;\">: Postal code of customer</span>**  ","metadata":{}},{"cell_type":"code","source":"pd.options.display.max_rows = 50\ncustomers.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:12.292476Z","iopub.execute_input":"2022-02-27T20:49:12.293231Z","iopub.status.idle":"2022-02-27T20:49:12.308324Z","shell.execute_reply.started":"2022-02-27T20:49:12.293165Z","shell.execute_reply":"2022-02-27T20:49:12.307345Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#quick_bar_chart('postal_code', (3, 3), False, customers, True)\nlen(customers)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:12.309578Z","iopub.execute_input":"2022-02-27T20:49:12.309801Z","iopub.status.idle":"2022-02-27T20:49:12.319925Z","shell.execute_reply.started":"2022-02-27T20:49:12.309772Z","shell.execute_reply":"2022-02-27T20:49:12.319393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_dups('postal_code', customers)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:12.320884Z","iopub.execute_input":"2022-02-27T20:49:12.321229Z","iopub.status.idle":"2022-02-27T20:49:13.669067Z","shell.execute_reply.started":"2022-02-27T20:49:12.321183Z","shell.execute_reply":"2022-02-27T20:49:13.667871Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('fashion_news_frequency', (3, 3), False, customers)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:13.671877Z","iopub.execute_input":"2022-02-27T20:49:13.672086Z","iopub.status.idle":"2022-02-27T20:49:14.158877Z","shell.execute_reply.started":"2022-02-27T20:49:13.672061Z","shell.execute_reply":"2022-02-27T20:49:14.158002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('club_member_status', (3, 3), False, customers)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:14.160373Z","iopub.execute_input":"2022-02-27T20:49:14.160667Z","iopub.status.idle":"2022-02-27T20:49:14.643158Z","shell.execute_reply.started":"2022-02-27T20:49:14.160629Z","shell.execute_reply":"2022-02-27T20:49:14.642598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers['age']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:14.644254Z","iopub.execute_input":"2022-02-27T20:49:14.644591Z","iopub.status.idle":"2022-02-27T20:49:14.652011Z","shell.execute_reply.started":"2022-02-27T20:49:14.644561Z","shell.execute_reply":"2022-02-27T20:49:14.651062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.max(customers['age']), np.min(customers['age']), np.mean(customers['age']), np.median(customers['age'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:49:14.653418Z","iopub.execute_input":"2022-02-27T20:49:14.653611Z","iopub.status.idle":"2022-02-27T20:49:14.699701Z","shell.execute_reply.started":"2022-02-27T20:49:14.653587Z","shell.execute_reply":"2022-02-27T20:49:14.699035Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10, 6), dpi=80)\nn, bins, patches = plt.hist(customers['age'], 99-16, density=False, facecolor='#CC071E')#, facecolor='g', alpha=0.75)\nplt.xlabel('Age (Years)')\nplt.ylabel('Count')\nplt.title('Histogram of H&M Customer Ages')\nplt.xlim(15, 100)\nplt.ylim(0, 70000)\nplt.grid(True)\nplt.xticks(np.arange(15, 105, step=5))\nplt.savefig(\"histogram-customer-ages.png\", dpi=80, format='png')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:37.519851Z","iopub.execute_input":"2022-02-27T21:21:37.520171Z","iopub.status.idle":"2022-02-27T21:21:38.043182Z","shell.execute_reply.started":"2022-02-27T21:21:37.520139Z","shell.execute_reply":"2022-02-27T21:21:38.040972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## **<span id=\"Transactions\" style=\"color:#023e8a;\">4. Transactions</span>**","metadata":{}},{"cell_type":"markdown","source":"[**<span style=\"color:#FEF1FE;background-color:#023e8a;border-radius: 5px;padding: 2px\">Go to Table of Content</span>**](#Content)","metadata":{}},{"cell_type":"markdown","source":"**<span style=\"color:#023e8a;\"> Transactions data description: </span>**\n\n> `t_dat` **<span style=\"color:#023e8a;\">: A unique identifier of every customer</span>**  \n> `customer_id` **<span style=\"color:#023e8a;\">: A unique identifier of every customer </span>**  **<span style=\"color:#FF0000;\">(in </span>** `customers` **<span style=\"color:#FF0000;\"> table)</span>**  \n> `article_id` **<span style=\"color:#023e8a;\">: A unique identifier of every article</span>**  **<span style=\"color:#FF0000;\">(in </span>** `articles` **<span style=\"color:#FF0000;\"> table)</span>**  \n> `price` **<span style=\"color:#023e8a;\">: Price of purchase</span>**  \n> `sales_channel_id` **<span style=\"color:#023e8a;\">: 1 or 2</span>**  ","metadata":{}},{"cell_type":"code","source":"transactions.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:47.635971Z","iopub.execute_input":"2022-02-27T21:21:47.636326Z","iopub.status.idle":"2022-02-27T21:21:47.648693Z","shell.execute_reply.started":"2022-02-27T21:21:47.636282Z","shell.execute_reply":"2022-02-27T21:21:47.647854Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(transactions)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:47.827347Z","iopub.execute_input":"2022-02-27T21:21:47.828422Z","iopub.status.idle":"2022-02-27T21:21:47.833270Z","shell.execute_reply.started":"2022-02-27T21:21:47.828360Z","shell.execute_reply":"2022-02-27T21:21:47.832705Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from datetime import datetime","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:48.005988Z","iopub.execute_input":"2022-02-27T21:21:48.006287Z","iopub.status.idle":"2022-02-27T21:21:48.010874Z","shell.execute_reply.started":"2022-02-27T21:21:48.006240Z","shell.execute_reply":"2022-02-27T21:21:48.009873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"datetime.strptime('Jun 1 2005  1:33PM', '%b %d %Y %I:%M%p')","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:48.191539Z","iopub.execute_input":"2022-02-27T21:21:48.191997Z","iopub.status.idle":"2022-02-27T21:21:48.198209Z","shell.execute_reply.started":"2022-02-27T21:21:48.191953Z","shell.execute_reply":"2022-02-27T21:21:48.197570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"datetime.strptime('2018-09-20', '%Y-%m-%d')","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:48.784613Z","iopub.execute_input":"2022-02-27T21:21:48.785060Z","iopub.status.idle":"2022-02-27T21:21:48.792589Z","shell.execute_reply.started":"2022-02-27T21:21:48.785030Z","shell.execute_reply":"2022-02-27T21:21:48.791855Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transactionsDay1 = {}\ntransactionsMonth1 = {}\nfor index in range(0, len(transactions['t_dat']),100):\n    \n    if index % int(len(transactions['t_dat'])/100) == 0:\n        print(index / len(transactions['t_dat']))\n\n    date = transactions['t_dat'][index]\n    \n    dateF = datetime.strptime(date, '%Y-%m-%d')\n    \n    dateS1 = dateF.strftime('%Y-%m-%d')\n    dateS2 = dateF.strftime('%Y-%m')\n    \n    if dateS1 not in transactionsDay1:\n        transactionsDay1[dateS1] = 0\n    \n    if dateS2 not in transactionsMonth1:\n        transactionsMonth1[dateS2] = 0\n    \n    transactionsDay1[dateS1] += 1\n    transactionsMonth1[dateS2] += 1\n    \ndatesDay = []\ntransactionsDay = []\nfor date in transactionsDay1.keys():\n    datesDay.append(datetime.strptime(date, '%Y-%m-%d'))\n    transactionsDay.append(transactionsDay1[date])\n    \ndatesDay7 = []\ntransactionsDay7 = []\ntransactionsDay7Avg = []\nfor i in range(0,len(datesDay)-7,7):\n    transactionsSum = 0\n    for j in range(i,i+7):\n        transactionsSum += transactionsDay[j]\n    \n    datesDay7.append(datesDay[i])\n    transactionsDay7.append(transactionsSum)\n    transactionsDay7Avg.append(transactionsSum/7)\n    \ndatesMonth = []\ntransactionsMonth = []\nfor date in transactionsMonth1.keys():\n    datesMonth.append(datetime.strptime(date, '%Y-%m'))\n    transactionsMonth.append(transactionsMonth1[date])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:51.368957Z","iopub.execute_input":"2022-02-27T21:21:51.370765Z","iopub.status.idle":"2022-02-27T21:21:59.263151Z","shell.execute_reply.started":"2022-02-27T21:21:51.370700Z","shell.execute_reply":"2022-02-27T21:21:59.262037Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.min(datesDay), np.max(datesDay), len(datesDay), len(datesDay)/365, datesDay[0:10]","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:59.266783Z","iopub.execute_input":"2022-02-27T21:21:59.267021Z","iopub.status.idle":"2022-02-27T21:21:59.277116Z","shell.execute_reply.started":"2022-02-27T21:21:59.266993Z","shell.execute_reply":"2022-02-27T21:21:59.276125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.min(datesMonth), np.max(datesMonth), len(datesMonth), len(datesMonth)/12","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:59.279113Z","iopub.execute_input":"2022-02-27T21:21:59.279393Z","iopub.status.idle":"2022-02-27T21:21:59.291045Z","shell.execute_reply.started":"2022-02-27T21:21:59.279362Z","shell.execute_reply":"2022-02-27T21:21:59.290212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.min(transactionsDay), np.max(transactionsDay), transactionsDay[0:10]","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:59.293618Z","iopub.execute_input":"2022-02-27T21:21:59.293868Z","iopub.status.idle":"2022-02-27T21:21:59.305032Z","shell.execute_reply.started":"2022-02-27T21:21:59.293840Z","shell.execute_reply":"2022-02-27T21:21:59.304406Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.min(transactionsMonth), np.max(transactionsMonth), transactionsMonth[0:10]","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:59.306236Z","iopub.execute_input":"2022-02-27T21:21:59.306496Z","iopub.status.idle":"2022-02-27T21:21:59.318143Z","shell.execute_reply.started":"2022-02-27T21:21:59.306467Z","shell.execute_reply":"2022-02-27T21:21:59.317333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10, 6), dpi=80)\nplt.plot_date(datesDay, transactionsDay)\nplt.grid(True)\nplt.xlabel('Date (YYYY-MM)')\nplt.ylabel('Number of Transactions')\nplt.title('Transactions per Day')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:59.319951Z","iopub.execute_input":"2022-02-27T21:21:59.320980Z","iopub.status.idle":"2022-02-27T21:21:59.596161Z","shell.execute_reply.started":"2022-02-27T21:21:59.320939Z","shell.execute_reply":"2022-02-27T21:21:59.595346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(10,6), dpi=80)\nax = fig.add_axes([0,0,1,1])\nax.bar(datesDay,transactionsDay)\nfig.align_labels()\nplt.xticks(rotation=45, ha='right', rotation_mode='anchor')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:21:59.597441Z","iopub.execute_input":"2022-02-27T21:21:59.598799Z","iopub.status.idle":"2022-02-27T21:22:00.949670Z","shell.execute_reply.started":"2022-02-27T21:21:59.598706Z","shell.execute_reply":"2022-02-27T21:22:00.948816Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(5, 3), dpi=80)\nplt.plot_date(datesDay7, transactionsDay7, color='#CC071E')\nplt.xlabel('Date (YYYY-MM)')\nplt.ylabel('Number of Transactions')\nplt.title('Transactions per Week')\nplt.xticks(rotation=45, ha='right', rotation_mode='anchor')\nplt.grid(True)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:26:08.318485Z","iopub.execute_input":"2022-02-27T21:26:08.318824Z","iopub.status.idle":"2022-02-27T21:26:08.543633Z","shell.execute_reply.started":"2022-02-27T21:26:08.318792Z","shell.execute_reply":"2022-02-27T21:26:08.542598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10, 6), dpi=80)\nplt.plot_date(datesDay7, transactionsDay7Avg)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:22:01.205396Z","iopub.execute_input":"2022-02-27T21:22:01.205622Z","iopub.status.idle":"2022-02-27T21:22:01.619426Z","shell.execute_reply.started":"2022-02-27T21:22:01.205594Z","shell.execute_reply":"2022-02-27T21:22:01.618474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10, 6), dpi=80)\nplt.plot_date(datesMonth, transactionsMonth, color='#CC071E')\nplt.xlabel('Date (YYYY-MM)')\nplt.ylabel('Number of Transactions')\nplt.title('Transactions per Month')\nplt.grid(True)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:24:57.098672Z","iopub.execute_input":"2022-02-27T21:24:57.098940Z","iopub.status.idle":"2022-02-27T21:24:57.330215Z","shell.execute_reply.started":"2022-02-27T21:24:57.098908Z","shell.execute_reply":"2022-02-27T21:24:57.329587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(10,6), dpi=80)\nax = fig.add_axes([0,0,1,1])\nax.bar(datesMonth,transactionsMonth)\nfig.align_labels()\nplt.xticks(rotation=45, ha='right', rotation_mode='anchor')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:22:01.876078Z","iopub.execute_input":"2022-02-27T21:22:01.876579Z","iopub.status.idle":"2022-02-27T21:22:02.168716Z","shell.execute_reply.started":"2022-02-27T21:22:01.876536Z","shell.execute_reply":"2022-02-27T21:22:02.168032Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"quick_bar_chart('t_dat', (3, 3), False, transactions)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:22:02.170255Z","iopub.execute_input":"2022-02-27T21:22:02.170756Z","iopub.status.idle":"2022-02-27T21:22:08.298110Z","shell.execute_reply.started":"2022-02-27T21:22:02.170711Z","shell.execute_reply":"2022-02-27T21:22:08.296877Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}