{"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":"# Otto: How Many ____? 🤷‍\n\n**There is a lot of data in the OTTO competition and a few things that I was curious about:**\n1. how many users?\n2. how many products?\n3. how many days?\n4. how many clicks, carts, or sales?\n\n**I added a CSV that was built using these two of my other OTTO notebooks:**\n\nhttps://www.kaggle.com/code/crained/otto-breaking-out-the-dates\n\nhttps://www.kaggle.com/code/crained/otto-clean-data","metadata":{}},{"cell_type":"code","source":"# bring in the packages we will need\nimport numpy as np\nimport pandas as pd","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-11-20T14:38:20.314669Z","iopub.execute_input":"2022-11-20T14:38:20.315496Z","iopub.status.idle":"2022-11-20T14:38:20.320400Z","shell.execute_reply.started":"2022-11-20T14:38:20.315462Z","shell.execute_reply":"2022-11-20T14:38:20.319423Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Add new CSV to explore data","metadata":{}},{"cell_type":"code","source":"directory = '../input/otto-cleanup-csv-repo/'\ntrain = pd.read_csv(directory+'otto-breaking-out-dates.csv')","metadata":{"execution":{"iopub.status.busy":"2022-11-20T14:38:22.526969Z","iopub.execute_input":"2022-11-20T14:38:22.527366Z","iopub.status.idle":"2022-11-20T14:38:45.775038Z","shell.execute_reply.started":"2022-11-20T14:38:22.527335Z","shell.execute_reply":"2022-11-20T14:38:45.773936Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-11-20T15:10:50.943918Z","iopub.execute_input":"2022-11-20T15:10:50.944326Z","iopub.status.idle":"2022-11-20T15:10:50.958160Z","shell.execute_reply.started":"2022-11-20T15:10:50.944291Z","shell.execute_reply":"2022-11-20T15:10:50.957412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# How many of each type per column?","metadata":{}},{"cell_type":"code","source":"# count of unique values in each column\nprint(train.nunique())","metadata":{"execution":{"iopub.status.busy":"2022-11-20T14:45:47.740730Z","iopub.execute_input":"2022-11-20T14:45:47.741126Z","iopub.status.idle":"2022-11-20T14:45:59.354438Z","shell.execute_reply.started":"2022-11-20T14:45:47.741096Z","shell.execute_reply":"2022-11-20T14:45:59.353208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# How many of each type per column breakdown:\n\n* 200,000 customers\n* 951,294 products\n* 1 year\n* 2 months\n* 7 days (thankfully or that'd be weird)\n* 24 hours (see 7 days :))\n* 3 event_types (clicks, carts,orders)","metadata":{}},{"cell_type":"markdown","source":"# What customers shopped the most? ","metadata":{}},{"cell_type":"code","source":"# unique customers and how often customers shop\ntrain_customers = train['customer_id'].value_counts()\nprint(train_customers)","metadata":{"execution":{"iopub.status.busy":"2022-11-20T14:43:14.273739Z","iopub.execute_input":"2022-11-20T14:43:14.274872Z","iopub.status.idle":"2022-11-20T14:43:14.477480Z","shell.execute_reply.started":"2022-11-20T14:43:14.274829Z","shell.execute_reply":"2022-11-20T14:43:14.476359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# What are the most popular products?","metadata":{}},{"cell_type":"code","source":"# unique products and how often they are clicked, put in cart, or bought\ntrain_products = train['product_code'].value_counts()\nprint(train_products)","metadata":{"execution":{"iopub.status.busy":"2022-11-20T15:01:22.652049Z","iopub.execute_input":"2022-11-20T15:01:22.652470Z","iopub.status.idle":"2022-11-20T15:01:23.296590Z","shell.execute_reply.started":"2022-11-20T15:01:22.652434Z","shell.execute_reply":"2022-11-20T15:01:23.295440Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**29735 is the most engaged product!**","metadata":{}},{"cell_type":"markdown","source":"# What is the busiest customer action (event_type)?","metadata":{}},{"cell_type":"code","source":"# unique products and how often they are clicked, put in cart, or bought\ntrain_events = train['event_type'].value_counts()\nprint(train_events)","metadata":{"execution":{"iopub.status.busy":"2022-11-20T15:12:35.647426Z","iopub.execute_input":"2022-11-20T15:12:35.648321Z","iopub.status.idle":"2022-11-20T15:12:36.276746Z","shell.execute_reply.started":"2022-11-20T15:12:35.648283Z","shell.execute_reply":"2022-11-20T15:12:36.275574Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**No surprise, there are a lot more clicks on products than adds to the cart or purchases. **","metadata":{}},{"cell_type":"markdown","source":"# What is the busiest month?","metadata":{}},{"cell_type":"code","source":"# Which month is the busiest?\ntrain_month = train['month'].value_counts()\nprint(train_month)","metadata":{"execution":{"iopub.status.busy":"2022-11-20T15:13:50.949854Z","iopub.execute_input":"2022-11-20T15:13:50.950663Z","iopub.status.idle":"2022-11-20T15:13:51.043148Z","shell.execute_reply.started":"2022-11-20T15:13:50.950616Z","shell.execute_reply":"2022-11-20T15:13:51.042026Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# What is the busiest day?","metadata":{}},{"cell_type":"code","source":"# Which day is the busiest?\ntrain_dat = train['day'].value_counts()\nprint(train_dat)","metadata":{"execution":{"iopub.status.busy":"2022-11-20T15:14:35.996519Z","iopub.execute_input":"2022-11-20T15:14:35.996900Z","iopub.status.idle":"2022-11-20T15:14:36.088685Z","shell.execute_reply.started":"2022-11-20T15:14:35.996869Z","shell.execute_reply":"2022-11-20T15:14:36.087611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Monday=1, Tuesday=2... until Sunday=7**\n\n**Monday is the busiest day. Saturday is the slowest.**","metadata":{}},{"cell_type":"markdown","source":"# What is the busiest hour?","metadata":{}},{"cell_type":"code","source":"# Which hour is the busiest?\ntrain_hour = train['hour'].value_counts()\nprint(train_hour)","metadata":{"execution":{"iopub.status.busy":"2022-11-20T15:14:58.767513Z","iopub.execute_input":"2022-11-20T15:14:58.768565Z","iopub.status.idle":"2022-11-20T15:14:58.859243Z","shell.execute_reply.started":"2022-11-20T15:14:58.768525Z","shell.execute_reply":"2022-11-20T15:14:58.858101Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**7 p.m. is the busiest shopping hour!**","metadata":{}},{"cell_type":"markdown","source":"# Upvote if this helped 🤓","metadata":{}}]}