diff --git "a/Appendix Data Review and Illustrative Example.html" "b/Appendix Data Review and Illustrative Example.html" new file mode 100644--- /dev/null +++ "b/Appendix Data Review and Illustrative Example.html" @@ -0,0 +1,13903 @@ + + + +Appendix Data Review and Illustrative Example + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+

To support the 2020 MSOM Data Driven Research Challenge dataset provided by JD.com, this document provides a simple illustrative example on what is in the data and how to connect the data between varies tables to make effective analysis. The notebook can be used as a reference to help understanding the dataset. It is als runnable using the dataset for data exploration as a Jupyter notebook. +For more detailed description of the data, data schema and underlying business scenario, please refer to the main document.

+ +
+
+
+
+
+
+
+

Prerequirements

+ +
+
+
+
+
+
In [1]:
+
+
+
import pandas as pd
+import numpy as np
+import datetime as dt
+
+ +
+
+
+ +
+
+
+
+
+

Load and View Data

+
+
+
+
+
+
+
+
    +
  • Loading all 7 data tables
  • +
+ +
+
+
+
+
+
In [2]:
+
+
+
# 'skus' table
+skus = pd.read_csv('JD_sku_data.csv')
+# 'users' table
+users = pd.read_csv('JD_user_data.csv')
+# 'clicks' table
+clicks = pd.read_csv('JD_click_data.csv')
+# 'orders' table
+orders = pd.read_csv('JD_order_data.csv')
+# 'delivery' table
+delivery = pd.read_csv('JD_delivery_data.csv')
+# 'inventory' table
+inventory = pd.read_csv('JD_inventory_data.csv')
+# 'network' table
+network = pd.read_csv('JD_network_data.csv')
+
+ +
+
+
+ +
+
+
+
+
+
    +
  • Sample of skus table
  • +
+ +
+
+
+
+
+
In [3]:
+
+
+
skus.head()
+
+ +
+
+
+ +
+
+ + +
+ +
Out[3]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
sku_IDtypebrand_IDattribute1attribute2activate_datedeactivate_date
0a234e08c571c3ab4bf4d93.060.0NaNNaN
16449e1fd8711d8b4b4c632.050.0NaNNaN
209b70fcd832eb7d2a675a3.070.0NaNNaN
3acad9fed0429b0d3a5fc63.070.0NaNNaN
42fa77e3b4d2b681299668--NaNNaN
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • Sample of user table
  • +
+ +
+
+
+
+
+
In [4]:
+
+
+
users.head()
+
+ +
+
+
+ +
+
+ + +
+ +
Out[4]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
user_IDuser_levelfirst_order_monthplusgenderagemarital_statuseducationcity_levelpurchase_power
0000089d6a612017-080F26-35S343
10000babd1f12018-030UUU-1-1-1
20000bc018b32016-060F>=56M323
30000d0e5ab32014-060M26-35M322
40000dce47232012-081UUU-1-1-1
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • Sample of clicks table
  • +
+ +
+
+
+
+
+
In [5]:
+
+
+
clicks.head()
+
+ +
+
+
+ +
+
+ + +
+ +
Out[5]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
sku_IDuser_IDrequest_timechannel
0a234e08c574c3d6d10c22018-03-01 23:57:53wechat
16449e1fd87-2018-03-01 16:13:48wechat
209b70fcd832791ec44852018-03-01 22:10:51wechat
309b70fcd83eb0718c1c92018-03-01 16:34:08wechat
409b70fcd8359f84cf3422018-03-01 22:20:35wechat
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • Sample of orders table
  • +
+ +
+
+
+
+
+
In [6]:
+
+
+
orders.head().T
+
+ +
+
+
+ +
+
+ + +
+ +
Out[6]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
01234
order_IDd0cf5cc6db7444318d01f973b016948c1cec8d4bd43a33c38a
user_ID0abe9ef2ce33a9e562574ea3cf408fb87cb736cb4829223b6f
sku_ID581d5b54c1067b673f2b623d0a582afc5289b139623d0a582a
order_date2018-03-012018-03-012018-03-012018-03-012018-03-01
order_time2018-03-01 17:14:25.02018-03-01 11:10:40.02018-03-01 09:13:26.02018-03-01 21:29:50.02018-03-01 19:13:37.0
quantity11111
type21111
promise-2221
original_unit_price8999.9786178
final_unit_price7953.958.53553
direct_discount_per_unit0519.5019
quantity_discount_per_unit10410260
bundle_discount_per_unit00000
coupon_discount_per_unit00006
gift_item00000
dc_ori4282843
dc_des2828282816
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • Sample of delivery table
  • +
+ +
+
+
+
+
+
In [7]:
+
+
+
delivery.head()
+
+ +
+
+
+ +
+
+ + +
+ +
Out[7]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
package_IDorder_IDtypeship_out_timearr_station_timearr_time
0dc3d6d2258dc3d6d225812018-03-01 08:00:002018-03-01 15:00:002018-03-01 18:00:00
119802a570c19802a570c12018-03-01 10:00:002018-03-01 15:00:002018-03-01 17:00:00
2e22627af66e22627af6612018-03-01 11:00:002018-03-01 15:00:002018-03-01 17:00:00
350d11a586d50d11a586d12018-03-01 10:00:002018-03-01 16:00:002018-03-01 19:00:00
4a3bfe38bf4a3bfe38bf412018-03-01 11:00:002018-03-01 16:00:002018-03-01 17:00:00
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • Sample of inventory table
  • +
+ +
+
+
+
+
+
In [8]:
+
+
+
inventory.head()
+
+ +
+
+
+ +
+
+ + +
+ +
Out[8]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dc_IDsku_IDdate
0950f6f919622018-03-01
197f0ddbcdde2018-03-01
298ad5789d742018-03-01
39468d34eda42018-03-01
49460afaddb62018-03-01
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • Sample of network table
  • +
+ +
+
+
+
+
+
In [9]:
+
+
+
network.head()
+
+ +
+
+
+ +
+
+ + +
+ +
Out[9]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
region_IDdc_ID
0257
1243
2242
3266
4220
+
+
+ +
+ +
+
+ +
+
+
+
+
+

An Illustrating Example of Full Customer Experience Cycle

+
+
+
+
+
+
+
+

We first randomly select a customer order with order_ID ‘81a6fa818d’ from the order table. The data below shows the information in orders table corresponding to the order.

+ +
+
+
+
+
+
In [10]:
+
+
+
orders[orders['order_ID']=='81a6fa818d'].T
+
+ +
+
+
+ +
+
+ + +
+ +
Out[10]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
4725347254
order_ID81a6fa818d81a6fa818d
user_ID2c511cbd9e2c511cbd9e
sku_IDac61f4e10eeb3f2d2fd8
order_date2018-03-022018-03-02
order_time2018-03-02 00:04:44.02018-03-02 00:04:44.0
quantity11
type11
promise11
original_unit_price139.9139.9
final_unit_price82.982.9
direct_discount_per_unit77
quantity_discount_per_unit5050
bundle_discount_per_unit00
coupon_discount_per_unit00
gift_item00
dc_ori99
dc_des2727
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • From the order table, we find that this order is placed by customer ‘2c511cbd9e’ on ‘2018-03-02’ and contains two SKUs with sku_ID ‘ac61f4e10e’ and 'eb3f2d2fd8'.
  • +
  • Also, we find that the customer took discount from a quantity discount of a total value RMB 100 [calculated as 100 = 50 (unit discount for sku 'ac61f4e10e') 1 (quantity for sku 'ac61f4e10e') + 50 (unit discount for sku 'eb3f2d2fd8') 1 (quantity for sku 'eb3f2d2fd8')], a direct discount of a total value RMB 14 and no other discounts.
  • +
  • The order is shipped from warehouse in district 9 to destination district 27.
  • +
+ +
+
+
+
+
+
+
+

Taking a deeper look at the customer with user_ID '2c511cbd9e' from users table.

+ +
+
+
+
+
+
In [11]:
+
+
+
users[users['user_ID']=='2c511cbd9e']
+
+ +
+
+
+ +
+
+ + +
+ +
Out[11]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
user_IDuser_levelfirst_order_monthplusgenderagemarital_statuseducationcity_levelpurchase_power
799442c511cbd9e32015-060F26-35M312
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • By looking up the customer ‘2c511cbd9e’ in the users table, we find that this is a level 3 user with no PLUS membership who has been with JD.com since 2015-06.
  • +
  • The customer's most common shipping address is in a tier 1 city.
  • +
  • The customer is estimated to be a married (marital_status = 'M') female customer (gender = 'F') in her 26-35th (age = '26-35') with a Bachelor degree (education = 3) and relatively high purchase power (purchase_power = 2).
  • +
+ +
+
+
+
+
+
+
+

Now checking the information available in the skus table for the related SKUs.

+ +
+
+
+
+
+
In [12]:
+
+
+
skus[skus['sku_ID'].isin(['ac61f4e10e','eb3f2d2fd8'])]
+
+ +
+
+
+ +
+
+ + +
+ +
Out[12]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
sku_IDtypebrand_IDattribute1attribute2activate_datedeactivate_date
1986eb3f2d2fd819b0d3a5fc6--NaNNaN
2813ac61f4e10e19b0d3a5fc63.080.0NaNNaN
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • By looking up the two SKUs bought in the skus table, we find that both of them are 1P skus and of the same brand. However, one item is missing the two provided attributes.
  • +
  • Both SKUs do not have activate_date and deactivate_date listed, meaning both SKUs are available for purchase during the whole month.
  • +
+ +
+
+
+
+
+
+
+

clicks table can also provide further information on how this purchase happened.

+ +
+
+
+
+
+
In [13]:
+
+
+
clicks[clicks['user_ID']=='2c511cbd9e'].sort_values('request_time')
+
+ +
+
+
+ +
+
+ + +
+ +
Out[13]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
sku_IDuser_IDrequest_timechannel
74424281e57cbc502c511cbd9e2018-03-01 23:17:21app
740110eb3f2d2fd82c511cbd9e2018-03-01 23:37:23app
740111eb3f2d2fd82c511cbd9e2018-03-01 23:37:50app
4705263c79df1d802c511cbd9e2018-03-01 23:37:52app
4705273c79df1d802c511cbd9e2018-03-01 23:38:06app
4705293c79df1d802c511cbd9e2018-03-01 23:38:21app
6135991a2362c2482c511cbd9e2018-03-01 23:38:36app
119316ac61f4e10e2c511cbd9e2018-03-01 23:38:43app
740108eb3f2d2fd82c511cbd9e2018-03-01 23:38:51app
119318ac61f4e10e2c511cbd9e2018-03-01 23:39:17app
119313ac61f4e10e2c511cbd9e2018-03-01 23:39:44app
357867d829f03a282c511cbd9e2018-03-01 23:39:51app
455350a1b0f574642c511cbd9e2018-03-01 23:39:53app
357865d829f03a282c511cbd9e2018-03-01 23:40:00app
455349a1b0f574642c511cbd9e2018-03-01 23:40:04app
4705303c79df1d802c511cbd9e2018-03-01 23:40:46app
455352a1b0f574642c511cbd9e2018-03-01 23:40:54app
455351a1b0f574642c511cbd9e2018-03-01 23:42:17app
119317ac61f4e10e2c511cbd9e2018-03-01 23:42:48app
119314ac61f4e10e2c511cbd9e2018-03-01 23:42:58app
455348a1b0f574642c511cbd9e2018-03-01 23:43:00app
4705313c79df1d802c511cbd9e2018-03-01 23:43:07app
119312ac61f4e10e2c511cbd9e2018-03-01 23:43:34app
740112eb3f2d2fd82c511cbd9e2018-03-01 23:43:53app
740109eb3f2d2fd82c511cbd9e2018-03-01 23:44:28app
74424381e57cbc502c511cbd9e2018-03-01 23:44:32app
154292fbce41fd822c511cbd9e2018-03-01 23:44:38app
305459068f4481b32c511cbd9e2018-03-01 23:44:46app
1446640d3ae2b3bf2c511cbd9e2018-03-01 23:45:06app
236290b9f08a2a2a2c511cbd9e2018-03-01 23:45:10app
377384d7d6bd5e1a2c511cbd9e2018-03-01 23:45:14app
9307605564787f402c511cbd9e2018-03-01 23:45:25app
154291fbce41fd822c511cbd9e2018-03-01 23:45:35app
18043738d636d2a62c511cbd9e2018-03-01 23:45:39app
305454068f4481b32c511cbd9e2018-03-01 23:45:48app
884761ff6f356b132c511cbd9e2018-03-01 23:45:53app
708769d47c6ca6312c511cbd9e2018-03-01 23:46:05app
5250237f947c00552c511cbd9e2018-03-01 23:46:55app
42440617b02965172c511cbd9e2018-03-01 23:47:34app
808099329698c3672c511cbd9e2018-03-01 23:58:54app
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • By looking up the same customer in the clicks table, we find that the customer has been browsing several items before making the purchase decision.
  • +
  • The sequence of browsing may suggest the customer was actively comparing between these substitutes as we see many back and forth clicks between several SKUs.
  • +
+ +
+
+
+
+
+
+
+

Now we look at how the order is fulfilled. Firstly we can look at the warehouse that is used to fulfill the order from orders table.

+ +
+
+
+
+
+
In [14]:
+
+
+
orders[orders['order_ID']=='81a6fa818d'][['sku_ID', 'dc_ori', 'dc_des']]
+
+ +
+
+
+ +
+
+ + +
+ +
Out[14]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
sku_IDdc_oridc_des
47253ac61f4e10e927
47254eb3f2d2fd8927
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • We can see that both SKUs are shipped from a wharehouse in district 9 to district 27 which is the final destination.
  • +
+ +
+
+
+
+
+
+
+

The delivery table can provide more details on the shipment information

+ +
+
+
+
+
+
In [15]:
+
+
+
delivery[delivery['order_ID']=='81a6fa818d']
+
+ +
+
+
+ +
+
+ + +
+ +
Out[15]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
package_IDorder_IDtypeship_out_timearr_station_timearr_time
1041581a6fa818d81a6fa818d12018-03-02 08:00:002018-03-02 15:00:002018-03-02 16:00:00
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • By looking up order '81a6fa818d' in the delivery table, we find that there is only one record, meaning the two purchased items are shipped together in one package. The associated package shipped out from warehouse shortly after the order is placed and arrived at the customer address in the morning of the next day.
  • +
+ +
+
+
+
+
+
+
+

The inventory table would be able to provide more insights on the fulfillment logic.

+ +
+
+
+
+
+
In [16]:
+
+
+
inventory[(inventory['sku_ID'].isin(['ac61f4e10e','eb3f2d2fd8'])) & \
+          (inventory['date']=='2018-03-01') & (inventory['dc_ID']==27)]
+
+ +
+
+
+ +
+
+ + +
+ +
Out[16]:
+ + + +
+
+ + + + + + + + + + + + +
dc_IDsku_IDdate
+
+
+ +
+ +
+
+ +
+
+
+
In [17]:
+
+
+
inventory[(inventory['sku_ID'].isin(['ac61f4e10e','eb3f2d2fd8'])) & \
+          (inventory['date']=='2018-03-01') & (inventory['dc_ID']==9)]
+
+ +
+
+
+ +
+
+ + +
+ +
Out[17]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
dc_IDsku_IDdate
10079ac61f4e10e2018-03-01
20209eb3f2d2fd82018-03-01
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • Note that the first statement returns no results, meaning warehouses in district 27 does not have any inventory of any of the SKUs.
  • +
  • The second statement returns two records, one for each SKU. This suggusts both SKUs are available in the warehouse.
  • +
  • This explains why the order is fulfilled from a remote warehouse (dc_ori is not the same as dc_des).
  • +
+ +
+
+
+
+
+
+
+

The fulfillment logic can be further clarified using the network table.

+ +
+
+
+
+
+
In [18]:
+
+
+
network[network['dc_ID'].isin([9, 27])]
+
+ +
+
+
+ +
+
+ + +
+ +
Out[18]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
region_IDdc_ID
3899
41927
+
+
+ +
+ +
+
+ +
+
+
+
+
+
    +
  • As explained in the data paper, when dc_ID = region_ID, the warehouses in this district are used as "central warehouses" for "back-up fulfillment" when local warehouses are run out of inventory or does not store the SKUs. In this particular case, dc_ID 9 is central warehouse. As we see previous that warehouses in disctrict 27 do not have any inventory for the two ordered SKUs, a warehouse in district 9 is used for the fulfillment of this order.
  • +
+ +
+
+
+
+
+ + + + + +