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_ID type brand_ID attribute1 attribute2 activate_date deactivate_date
0 a234e08c57 1 c3ab4bf4d9 3.0 60.0 NaN NaN
1 6449e1fd87 1 1d8b4b4c63 2.0 50.0 NaN NaN
2 09b70fcd83 2 eb7d2a675a 3.0 70.0 NaN NaN
3 acad9fed04 2 9b0d3a5fc6 3.0 70.0 NaN NaN
4 2fa77e3b4d 2 b681299668 - - NaN NaN
  • Sample of user table
In [4]:
users.head()
Out[4]:
user_ID user_level first_order_month plus gender age marital_status education city_level purchase_power
0 000089d6a6 1 2017-08 0 F 26-35 S 3 4 3
1 0000babd1f 1 2018-03 0 U U U -1 -1 -1
2 0000bc018b 3 2016-06 0 F >=56 M 3 2 3
3 0000d0e5ab 3 2014-06 0 M 26-35 M 3 2 2
4 0000dce472 3 2012-08 1 U U U -1 -1 -1
  • Sample of clicks table
In [5]:
clicks.head()
Out[5]:
sku_ID user_ID request_time channel
0 a234e08c57 4c3d6d10c2 2018-03-01 23:57:53 wechat
1 6449e1fd87 - 2018-03-01 16:13:48 wechat
2 09b70fcd83 2791ec4485 2018-03-01 22:10:51 wechat
3 09b70fcd83 eb0718c1c9 2018-03-01 16:34:08 wechat
4 09b70fcd83 59f84cf342 2018-03-01 22:20:35 wechat
  • Sample of orders table
In [6]:
orders.head().T
Out[6]:
0 1 2 3 4
order_ID d0cf5cc6db 7444318d01 f973b01694 8c1cec8d4b d43a33c38a
user_ID 0abe9ef2ce 33a9e56257 4ea3cf408f b87cb736cb 4829223b6f
sku_ID 581d5b54c1 067b673f2b 623d0a582a fc5289b139 623d0a582a
order_date 2018-03-01 2018-03-01 2018-03-01 2018-03-01 2018-03-01
order_time 2018-03-01 17:14:25.0 2018-03-01 11:10:40.0 2018-03-01 09:13:26.0 2018-03-01 21:29:50.0 2018-03-01 19:13:37.0
quantity 1 1 1 1 1
type 2 1 1 1 1
promise - 2 2 2 1
original_unit_price 89 99.9 78 61 78
final_unit_price 79 53.9 58.5 35 53
direct_discount_per_unit 0 5 19.5 0 19
quantity_discount_per_unit 10 41 0 26 0
bundle_discount_per_unit 0 0 0 0 0
coupon_discount_per_unit 0 0 0 0 6
gift_item 0 0 0 0 0
dc_ori 4 28 28 4 3
dc_des 28 28 28 28 16
  • Sample of delivery table
In [7]:
delivery.head()
Out[7]:
package_ID order_ID type ship_out_time arr_station_time arr_time
0 dc3d6d2258 dc3d6d2258 1 2018-03-01 08:00:00 2018-03-01 15:00:00 2018-03-01 18:00:00
1 19802a570c 19802a570c 1 2018-03-01 10:00:00 2018-03-01 15:00:00 2018-03-01 17:00:00
2 e22627af66 e22627af66 1 2018-03-01 11:00:00 2018-03-01 15:00:00 2018-03-01 17:00:00
3 50d11a586d 50d11a586d 1 2018-03-01 10:00:00 2018-03-01 16:00:00 2018-03-01 19:00:00
4 a3bfe38bf4 a3bfe38bf4 1 2018-03-01 11:00:00 2018-03-01 16:00:00 2018-03-01 17:00:00
  • Sample of inventory table
In [8]:
inventory.head()
Out[8]:
dc_ID sku_ID date
0 9 50f6f91962 2018-03-01
1 9 7f0ddbcdde 2018-03-01
2 9 8ad5789d74 2018-03-01
3 9 468d34eda4 2018-03-01
4 9 460afaddb6 2018-03-01
  • Sample of network table
In [9]:
network.head()
Out[9]:
region_ID dc_ID
0 2 57
1 2 43
2 2 42
3 2 66
4 2 20

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]:
47253 47254
order_ID 81a6fa818d 81a6fa818d
user_ID 2c511cbd9e 2c511cbd9e
sku_ID ac61f4e10e eb3f2d2fd8
order_date 2018-03-02 2018-03-02
order_time 2018-03-02 00:04:44.0 2018-03-02 00:04:44.0
quantity 1 1
type 1 1
promise 1 1
original_unit_price 139.9 139.9
final_unit_price 82.9 82.9
direct_discount_per_unit 7 7
quantity_discount_per_unit 50 50
bundle_discount_per_unit 0 0
coupon_discount_per_unit 0 0
gift_item 0 0
dc_ori 9 9
dc_des 27 27
  • 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_ID user_level first_order_month plus gender age marital_status education city_level purchase_power
79944 2c511cbd9e 3 2015-06 0 F 26-35 M 3 1 2
  • 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_ID type brand_ID attribute1 attribute2 activate_date deactivate_date
1986 eb3f2d2fd8 1 9b0d3a5fc6 - - NaN NaN
2813 ac61f4e10e 1 9b0d3a5fc6 3.0 80.0 NaN NaN
  • 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_ID user_ID request_time channel
744242 81e57cbc50 2c511cbd9e 2018-03-01 23:17:21 app
740110 eb3f2d2fd8 2c511cbd9e 2018-03-01 23:37:23 app
740111 eb3f2d2fd8 2c511cbd9e 2018-03-01 23:37:50 app
470526 3c79df1d80 2c511cbd9e 2018-03-01 23:37:52 app
470527 3c79df1d80 2c511cbd9e 2018-03-01 23:38:06 app
470529 3c79df1d80 2c511cbd9e 2018-03-01 23:38:21 app
613599 1a2362c248 2c511cbd9e 2018-03-01 23:38:36 app
119316 ac61f4e10e 2c511cbd9e 2018-03-01 23:38:43 app
740108 eb3f2d2fd8 2c511cbd9e 2018-03-01 23:38:51 app
119318 ac61f4e10e 2c511cbd9e 2018-03-01 23:39:17 app
119313 ac61f4e10e 2c511cbd9e 2018-03-01 23:39:44 app
357867 d829f03a28 2c511cbd9e 2018-03-01 23:39:51 app
455350 a1b0f57464 2c511cbd9e 2018-03-01 23:39:53 app
357865 d829f03a28 2c511cbd9e 2018-03-01 23:40:00 app
455349 a1b0f57464 2c511cbd9e 2018-03-01 23:40:04 app
470530 3c79df1d80 2c511cbd9e 2018-03-01 23:40:46 app
455352 a1b0f57464 2c511cbd9e 2018-03-01 23:40:54 app
455351 a1b0f57464 2c511cbd9e 2018-03-01 23:42:17 app
119317 ac61f4e10e 2c511cbd9e 2018-03-01 23:42:48 app
119314 ac61f4e10e 2c511cbd9e 2018-03-01 23:42:58 app
455348 a1b0f57464 2c511cbd9e 2018-03-01 23:43:00 app
470531 3c79df1d80 2c511cbd9e 2018-03-01 23:43:07 app
119312 ac61f4e10e 2c511cbd9e 2018-03-01 23:43:34 app
740112 eb3f2d2fd8 2c511cbd9e 2018-03-01 23:43:53 app
740109 eb3f2d2fd8 2c511cbd9e 2018-03-01 23:44:28 app
744243 81e57cbc50 2c511cbd9e 2018-03-01 23:44:32 app
154292 fbce41fd82 2c511cbd9e 2018-03-01 23:44:38 app
305459 068f4481b3 2c511cbd9e 2018-03-01 23:44:46 app
144664 0d3ae2b3bf 2c511cbd9e 2018-03-01 23:45:06 app
236290 b9f08a2a2a 2c511cbd9e 2018-03-01 23:45:10 app
377384 d7d6bd5e1a 2c511cbd9e 2018-03-01 23:45:14 app
930760 5564787f40 2c511cbd9e 2018-03-01 23:45:25 app
154291 fbce41fd82 2c511cbd9e 2018-03-01 23:45:35 app
180437 38d636d2a6 2c511cbd9e 2018-03-01 23:45:39 app
305454 068f4481b3 2c511cbd9e 2018-03-01 23:45:48 app
884761 ff6f356b13 2c511cbd9e 2018-03-01 23:45:53 app
708769 d47c6ca631 2c511cbd9e 2018-03-01 23:46:05 app
525023 7f947c0055 2c511cbd9e 2018-03-01 23:46:55 app
424406 17b0296517 2c511cbd9e 2018-03-01 23:47:34 app
808099 329698c367 2c511cbd9e 2018-03-01 23:58:54 app
  • 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_ID dc_ori dc_des
47253 ac61f4e10e 9 27
47254 eb3f2d2fd8 9 27
  • 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_ID order_ID type ship_out_time arr_station_time arr_time
10415 81a6fa818d 81a6fa818d 1 2018-03-02 08:00:00 2018-03-02 15:00:00 2018-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_ID sku_ID date
In [17]:
inventory[(inventory['sku_ID'].isin(['ac61f4e10e','eb3f2d2fd8'])) & \
          (inventory['date']=='2018-03-01') & (inventory['dc_ID']==9)]
Out[17]:
dc_ID sku_ID date
1007 9 ac61f4e10e 2018-03-01
2020 9 eb3f2d2fd8 2018-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_ID dc_ID
38 9 9
41 9 27
  • 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.