Joining Data Sets¶
Let us perform few tasks to understand how to perform joins over multiple collections using loops and conditionals.
- There are different strategies for joins.
- Nested Loops
- Sort Merge
- Hash Join
- We will be using Nested Loops approach using orders and order_items.
- Build dict for one data set – orders.
- Iteratively lookup into the orders data set while processing the other one – order_items
- Develop a function get_daily_revenue which takes orders, order_items and order_status as arguments and return dict containing order_date and order_revenue. We need to get revenue considering only those orders which satisfy the status passed.
In [1]:
%run 07_preparing_data_sets.ipynb
In [2]:
orders[:10]
Out[2]:
['1,2013-07-25 00:00:00.0,11599,CLOSED', '2,2013-07-25 00:00:00.0,256,PENDING_PAYMENT', '3,2013-07-25 00:00:00.0,12111,COMPLETE', '4,2013-07-25 00:00:00.0,8827,CLOSED', '5,2013-07-25 00:00:00.0,11318,COMPLETE', '6,2013-07-25 00:00:00.0,7130,COMPLETE', '7,2013-07-25 00:00:00.0,4530,COMPLETE', '8,2013-07-25 00:00:00.0,2911,PROCESSING', '9,2013-07-25 00:00:00.0,5657,PENDING_PAYMENT', '10,2013-07-25 00:00:00.0,5648,PENDING_PAYMENT']
In [3]:
len(orders)
Out[3]:
68883
In [4]:
order_items[:10]
Out[4]:
['1,1,957,1,299.98,299.98', '2,2,1073,1,199.99,199.99', '3,2,502,5,250.0,50.0', '4,2,403,1,129.99,129.99', '5,4,897,2,49.98,24.99', '6,4,365,5,299.95,59.99', '7,4,502,3,150.0,50.0', '8,4,1014,4,199.92,49.98', '9,5,957,1,299.98,299.98', '10,5,365,5,299.95,59.99']
In [5]:
len(order_items)
Out[5]:
172198
In [6]:
def get_orders_dict(orders, order_status):
orders_dict = {}
for order in orders:
order_details = order.split(',')
if order_details[3] == order_status:
orders_dict[int(order_details[0])] = order_details[1]
return orders_dict
In [7]:
list(get_orders_dict(orders, 'COMPLETE').items())[:10]
Out[7]:
[(3, '2013-07-25 00:00:00.0'), (5, '2013-07-25 00:00:00.0'), (6, '2013-07-25 00:00:00.0'), (7, '2013-07-25 00:00:00.0'), (15, '2013-07-25 00:00:00.0'), (17, '2013-07-25 00:00:00.0'), (22, '2013-07-25 00:00:00.0'), (26, '2013-07-25 00:00:00.0'), (28, '2013-07-25 00:00:00.0'), (32, '2013-07-25 00:00:00.0')]
In [8]:
get_orders_dict(orders, 'COMPLETE')[3]
Out[8]:
'2013-07-25 00:00:00.0'
In [9]:
get_orders_dict(orders, 'COMPLETE').get(3)
Out[9]:
'2013-07-25 00:00:00.0'
In [10]:
len(get_orders_dict(orders, 'COMPLETE'))
Out[10]:
22899
In [11]:
orders_dict = get_orders_dict(orders, 'COMPLETE')
In [12]:
order_item = order_items[0]
order_item
Out[12]:
'1,1,957,1,299.98,299.98'
In [13]:
int(order_item.split(',')[1]) # order_id
Out[13]:
1
In [14]:
int(order_item.split(',')[1]) in orders_dict
Out[14]:
False
In [15]:
3 in orders_dict
Out[15]:
True
In [16]:
def get_daily_revenue(orders, order_items, order_status):
orders_dict = get_orders_dict(orders, order_status) # dict with order_id as key and order_date as value
daily_revenue = {} # Initializing empty dict to have date and corresponding revenue
for order_item in order_items:
# Processing all order_items
order_item_order_id = int(order_item.split(',')[1])
order_item_subtotal = float(order_item.split(',')[4])
if order_item_order_id in orders_dict:
# Look up into orders_dict using order_id to get order_date
orders_dict_date = orders_dict[order_item_order_id]
if orders_dict_date in daily_revenue:
# If order_date exists in orders_dict then add order_item_subtotal to the existing value
# based up on the key in daily_revenue
daily_revenue[orders_dict_date] = round(daily_revenue[orders_dict_date] + order_item_subtotal, 2)
else:
# If order_date does not exists then add new element to daily_revenue
daily_revenue[orders_dict_date] = order_item_subtotal
return daily_revenue
In [17]:
orders_sample = [
'4,2013-07-25 00:00:00.0,8827,CLOSED',
'5,2013-07-25 00:00:00.0,11318,COMPLETE',
'7,2013-07-25 00:00:00.0,4530,COMPLETE',
'105,2013-07-26 00:00:00.0,8220,COMPLETE'
]
In [18]:
order_items_sample = [
'5,4,897,2,49.98,24.99',
'6,4,365,5,299.95,59.99',
'7,4,502,3,150.0,50.0',
'8,4,1014,4,199.92,49.98',
'9,5,957,1,299.98,299.98',
'10,5,365,5,299.95,59.99',
'11,5,1014,2,99.96,49.98',
'12,5,957,1,299.98,299.98',
'13,5,403,1,129.99,129.99',
'14,7,1073,1,199.99,199.99',
'15,7,957,1,299.98,299.98',
'16,7,926,5,79.95,15.99',
'239,105,403,1,129.99,129.99',
'240,105,365,3,179.97,59.99',
'241,105,365,2,119.98,59.99'
]
In [19]:
get_daily_revenue(orders_sample, order_items_sample, 'COMPLETE')
Out[19]:
{'2013-07-25 00:00:00.0': 1709.78, '2013-07-26 00:00:00.0': 429.94}
{note}
Use the function to get daily revenue considering only COMPLETE orders.
In [20]:
get_daily_revenue(orders, order_items, 'COMPLETE')
Out[20]:
{'2013-07-25 00:00:00.0': 20030.32, '2013-07-26 00:00:00.0': 42165.88, '2013-07-27 00:00:00.0': 33156.21, '2013-07-28 00:00:00.0': 27012.91, '2013-07-29 00:00:00.0': 45898.65, '2013-07-30 00:00:00.0': 40590.21, '2013-07-31 00:00:00.0': 46503.83, '2013-08-01 00:00:00.0': 38231.41, '2013-08-02 00:00:00.0': 36633.44, '2013-08-03 00:00:00.0': 34828.71, '2013-08-04 00:00:00.0': 26161.97, '2013-08-05 00:00:00.0': 25804.33, '2013-08-06 00:00:00.0': 41413.79, '2013-08-07 00:00:00.0': 31533.1, '2013-08-08 00:00:00.0': 27359.07, '2013-08-09 00:00:00.0': 22091.95, '2013-08-10 00:00:00.0': 39038.72, '2013-08-11 00:00:00.0': 21302.69, '2013-08-12 00:00:00.0': 41139.11, '2013-08-13 00:00:00.0': 12468.53, '2013-08-14 00:00:00.0': 29760.88, '2013-08-15 00:00:00.0': 37473.12, '2013-08-16 00:00:00.0': 25547.74, '2013-08-17 00:00:00.0': 52940.94, '2013-08-18 00:00:00.0': 31304.59, '2013-08-19 00:00:00.0': 10603.87, '2013-08-20 00:00:00.0': 32680.05, '2013-08-21 00:00:00.0': 20326.67, '2013-08-22 00:00:00.0': 30542.99, '2013-08-23 00:00:00.0': 25676.67, '2013-08-24 00:00:00.0': 39566.76, '2013-08-25 00:00:00.0': 24176.98, '2013-08-26 00:00:00.0': 32764.19, '2013-08-27 00:00:00.0': 29917.18, '2013-08-28 00:00:00.0': 15508.83, '2013-08-29 00:00:00.0': 29657.13, '2013-08-30 00:00:00.0': 16826.35, '2013-08-31 00:00:00.0': 23916.02, '2013-09-01 00:00:00.0': 28224.43, '2013-09-02 00:00:00.0': 36572.45, '2013-09-03 00:00:00.0': 33598.37, '2013-09-04 00:00:00.0': 14672.73, '2013-09-05 00:00:00.0': 43742.2, '2013-09-06 00:00:00.0': 42171.36, '2013-09-07 00:00:00.0': 32440.08, '2013-09-08 00:00:00.0': 26988.11, '2013-09-09 00:00:00.0': 37805.85, '2013-09-10 00:00:00.0': 37044.81, '2013-09-11 00:00:00.0': 13959.96, '2013-09-12 00:00:00.0': 29668.41, '2013-09-13 00:00:00.0': 16894.24, '2013-09-14 00:00:00.0': 50099.43, '2013-09-15 00:00:00.0': 21931.71, '2013-09-16 00:00:00.0': 19308.73, '2013-09-17 00:00:00.0': 18827.31, '2013-09-18 00:00:00.0': 36194.59, '2013-09-19 00:00:00.0': 41831.29, '2013-09-20 00:00:00.0': 23230.05, '2013-09-21 00:00:00.0': 22988.28, '2013-09-22 00:00:00.0': 32105.07, '2013-09-23 00:00:00.0': 36075.92, '2013-09-24 00:00:00.0': 36712.37, '2013-09-25 00:00:00.0': 44628.96, '2013-09-26 00:00:00.0': 51404.02, '2013-09-27 00:00:00.0': 43653.31, '2013-09-28 00:00:00.0': 27721.5, '2013-09-29 00:00:00.0': 26244.91, '2013-09-30 00:00:00.0': 37202.86, '2013-10-01 00:00:00.0': 18622.05, '2013-10-02 00:00:00.0': 38284.92, '2013-10-03 00:00:00.0': 31431.93, '2013-10-04 00:00:00.0': 43874.09, '2013-10-05 00:00:00.0': 33440.09, '2013-10-06 00:00:00.0': 38882.82, '2013-10-07 00:00:00.0': 18696.85, '2013-10-08 00:00:00.0': 38930.45, '2013-10-09 00:00:00.0': 20241.56, '2013-10-10 00:00:00.0': 31290.32, '2013-10-11 00:00:00.0': 35022.43, '2013-10-12 00:00:00.0': 28034.86, '2013-10-13 00:00:00.0': 48405.18, '2013-10-14 00:00:00.0': 18882.35, '2013-10-15 00:00:00.0': 24112.48, '2013-10-16 00:00:00.0': 21025.27, '2013-10-17 00:00:00.0': 29120.53, '2013-10-18 00:00:00.0': 20948.94, '2013-10-19 00:00:00.0': 24107.06, '2013-10-20 00:00:00.0': 27366.67, '2013-10-21 00:00:00.0': 19230.94, '2013-10-22 00:00:00.0': 20437.38, '2013-10-23 00:00:00.0': 41052.82, '2013-10-24 00:00:00.0': 18946.1, '2013-10-25 00:00:00.0': 30551.7, '2013-10-26 00:00:00.0': 26521.1, '2013-10-27 00:00:00.0': 36942.7, '2013-10-28 00:00:00.0': 22706.3, '2013-10-29 00:00:00.0': 23544.26, '2013-10-30 00:00:00.0': 16798.86, '2013-10-31 00:00:00.0': 29819.85, '2013-11-01 00:00:00.0': 45791.7, '2013-11-02 00:00:00.0': 25631.21, '2013-11-03 00:00:00.0': 57212.85, '2013-11-04 00:00:00.0': 34211.06, '2013-11-05 00:00:00.0': 41651.39, '2013-11-06 00:00:00.0': 43085.8, '2013-11-07 00:00:00.0': 40661.6, '2013-11-08 00:00:00.0': 28307.46, '2013-11-09 00:00:00.0': 40240.44, '2013-11-10 00:00:00.0': 21337.46, '2013-11-11 00:00:00.0': 42214.68, '2013-11-12 00:00:00.0': 24111.96, '2013-11-13 00:00:00.0': 40188.16, '2013-11-14 00:00:00.0': 46206.7, '2013-11-15 00:00:00.0': 31043.53, '2013-11-16 00:00:00.0': 19151.7, '2013-11-17 00:00:00.0': 25144.36, '2013-11-18 00:00:00.0': 31469.73, '2013-11-19 00:00:00.0': 30258.22, '2013-11-20 00:00:00.0': 34164.75, '2013-11-21 00:00:00.0': 19412.81, '2013-11-22 00:00:00.0': 39561.64, '2013-11-23 00:00:00.0': 39698.28, '2013-11-24 00:00:00.0': 33962.17, '2013-11-25 00:00:00.0': 18878.51, '2013-11-26 00:00:00.0': 28637.23, '2013-11-27 00:00:00.0': 19771.52, '2013-11-28 00:00:00.0': 43544.74, '2013-11-29 00:00:00.0': 44914.53, '2013-11-30 00:00:00.0': 49901.39, '2013-12-01 00:00:00.0': 35147.85, '2013-12-02 00:00:00.0': 12875.48, '2013-12-03 00:00:00.0': 46867.78, '2013-12-04 00:00:00.0': 25200.64, '2013-12-05 00:00:00.0': 25887.67, '2013-12-06 00:00:00.0': 53368.29, '2013-12-07 00:00:00.0': 44045.8, '2013-12-08 00:00:00.0': 19174.89, '2013-12-09 00:00:00.0': 19887.9, '2013-12-10 00:00:00.0': 24741.51, '2013-12-11 00:00:00.0': 46870.39, '2013-12-12 00:00:00.0': 27399.66, '2013-12-13 00:00:00.0': 19538.79, '2013-12-14 00:00:00.0': 16767.31, '2013-12-15 00:00:00.0': 36907.04, '2013-12-16 00:00:00.0': 8019.08, '2013-12-17 00:00:00.0': 13673.72, '2013-12-18 00:00:00.0': 35229.96, '2013-12-19 00:00:00.0': 22047.64, '2013-12-20 00:00:00.0': 36022.42, '2013-12-21 00:00:00.0': 31613.01, '2013-12-22 00:00:00.0': 38058.83, '2013-12-23 00:00:00.0': 19945.33, '2013-12-24 00:00:00.0': 29206.62, '2013-12-25 00:00:00.0': 41778.41, '2013-12-26 00:00:00.0': 44547.15, '2013-12-27 00:00:00.0': 24562.11, '2013-12-28 00:00:00.0': 33838.05, '2013-12-29 00:00:00.0': 21752.61, '2013-12-30 00:00:00.0': 36728.69, '2013-12-31 00:00:00.0': 37957.83, '2014-01-01 00:00:00.0': 25282.12, '2014-01-02 00:00:00.0': 17503.07, '2014-01-03 00:00:00.0': 41479.36, '2014-01-04 00:00:00.0': 25711.38, '2014-01-05 00:00:00.0': 45781.13, '2014-01-06 00:00:00.0': 20705.45, '2014-01-07 00:00:00.0': 26302.87, '2014-01-08 00:00:00.0': 18313.0, '2014-01-09 00:00:00.0': 30042.74, '2014-01-10 00:00:00.0': 41257.47, '2014-01-11 00:00:00.0': 43901.48, '2014-01-12 00:00:00.0': 28347.76, '2014-01-13 00:00:00.0': 25911.78, '2014-01-14 00:00:00.0': 34580.61, '2014-01-15 00:00:00.0': 37343.83, '2014-01-16 00:00:00.0': 29499.85, '2014-01-17 00:00:00.0': 23151.15, '2014-01-18 00:00:00.0': 23402.29, '2014-01-19 00:00:00.0': 29404.62, '2014-01-20 00:00:00.0': 32716.38, '2014-01-21 00:00:00.0': 38683.67, '2014-01-22 00:00:00.0': 33530.81, '2014-01-23 00:00:00.0': 29472.05, '2014-01-24 00:00:00.0': 25281.2, '2014-01-25 00:00:00.0': 20115.05, '2014-01-26 00:00:00.0': 24456.18, '2014-01-27 00:00:00.0': 23521.46, '2014-01-28 00:00:00.0': 30685.46, '2014-01-29 00:00:00.0': 30290.05, '2014-01-30 00:00:00.0': 47273.68, '2014-01-31 00:00:00.0': 28037.76, '2014-02-01 00:00:00.0': 48115.36, '2014-02-02 00:00:00.0': 36368.75, '2014-02-03 00:00:00.0': 24773.62, '2014-02-04 00:00:00.0': 25177.37, '2014-02-05 00:00:00.0': 24515.22, '2014-02-06 00:00:00.0': 36850.7, '2014-02-07 00:00:00.0': 43856.83, '2014-02-08 00:00:00.0': 26527.02, '2014-02-09 00:00:00.0': 40137.71, '2014-02-10 00:00:00.0': 30502.69, '2014-02-11 00:00:00.0': 37184.37, '2014-02-12 00:00:00.0': 34901.6, '2014-02-13 00:00:00.0': 30811.55, '2014-02-14 00:00:00.0': 29085.94, '2014-02-15 00:00:00.0': 33802.84, '2014-02-16 00:00:00.0': 44126.41, '2014-02-17 00:00:00.0': 23147.33, '2014-02-18 00:00:00.0': 35835.12, '2014-02-19 00:00:00.0': 48966.83, '2014-02-20 00:00:00.0': 25698.65, '2014-02-21 00:00:00.0': 31009.6, '2014-02-22 00:00:00.0': 19181.75, '2014-02-23 00:00:00.0': 17894.94, '2014-02-24 00:00:00.0': 32420.29, '2014-02-25 00:00:00.0': 40888.54, '2014-02-26 00:00:00.0': 21705.14, '2014-02-27 00:00:00.0': 30835.3, '2014-02-28 00:00:00.0': 40812.57, '2014-03-01 00:00:00.0': 41382.32, '2014-03-02 00:00:00.0': 20397.77, '2014-03-03 00:00:00.0': 40290.55, '2014-03-04 00:00:00.0': 48069.04, '2014-03-05 00:00:00.0': 29798.85, '2014-03-06 00:00:00.0': 33242.3, '2014-03-07 00:00:00.0': 27395.75, '2014-03-08 00:00:00.0': 25289.65, '2014-03-10 00:00:00.0': 33899.78, '2014-03-11 00:00:00.0': 40639.48, '2014-03-12 00:00:00.0': 42742.02, '2014-03-13 00:00:00.0': 24204.25, '2014-03-14 00:00:00.0': 29845.57, '2014-03-15 00:00:00.0': 46261.47, '2014-03-16 00:00:00.0': 31197.23, '2014-03-17 00:00:00.0': 18938.98, '2014-03-18 00:00:00.0': 36967.51, '2014-03-19 00:00:00.0': 26098.59, '2014-03-20 00:00:00.0': 33996.15, '2014-03-21 00:00:00.0': 31027.52, '2014-03-22 00:00:00.0': 31650.5, '2014-03-23 00:00:00.0': 40011.28, '2014-03-24 00:00:00.0': 23847.21, '2014-03-25 00:00:00.0': 19780.6, '2014-03-26 00:00:00.0': 42382.4, '2014-03-27 00:00:00.0': 19719.02, '2014-03-28 00:00:00.0': 25668.33, '2014-03-29 00:00:00.0': 21106.74, '2014-03-30 00:00:00.0': 42448.24, '2014-03-31 00:00:00.0': 41378.04, '2014-04-01 00:00:00.0': 33056.89, '2014-04-02 00:00:00.0': 44430.33, '2014-04-03 00:00:00.0': 49942.93, '2014-04-04 00:00:00.0': 34072.28, '2014-04-05 00:00:00.0': 31575.26, '2014-04-06 00:00:00.0': 19200.22, '2014-04-07 00:00:00.0': 14197.38, '2014-04-08 00:00:00.0': 54214.37, '2014-04-09 00:00:00.0': 43104.94, '2014-04-10 00:00:00.0': 40666.25, '2014-04-11 00:00:00.0': 23333.98, '2014-04-12 00:00:00.0': 35639.09, '2014-04-13 00:00:00.0': 21509.74, '2014-04-14 00:00:00.0': 16650.04, '2014-04-15 00:00:00.0': 38057.54, '2014-04-16 00:00:00.0': 27121.01, '2014-04-17 00:00:00.0': 15760.05, '2014-04-18 00:00:00.0': 37875.53, '2014-04-19 00:00:00.0': 13152.65, '2014-04-20 00:00:00.0': 34014.07, '2014-04-21 00:00:00.0': 49522.07, '2014-04-22 00:00:00.0': 24719.15, '2014-04-23 00:00:00.0': 38942.88, '2014-04-24 00:00:00.0': 14013.33, '2014-04-25 00:00:00.0': 40560.08, '2014-04-26 00:00:00.0': 41386.63, '2014-04-27 00:00:00.0': 36426.21, '2014-04-28 00:00:00.0': 19309.81, '2014-04-29 00:00:00.0': 38458.54, '2014-04-30 00:00:00.0': 20850.89, '2014-05-01 00:00:00.0': 30957.47, '2014-05-02 00:00:00.0': 33456.28, '2014-05-03 00:00:00.0': 32350.29, '2014-05-04 00:00:00.0': 22027.02, '2014-05-05 00:00:00.0': 28034.0, '2014-05-06 00:00:00.0': 41467.72, '2014-05-07 00:00:00.0': 35490.3, '2014-05-08 00:00:00.0': 19789.73, '2014-05-09 00:00:00.0': 43436.97, '2014-05-10 00:00:00.0': 31074.21, '2014-05-11 00:00:00.0': 36289.84, '2014-05-12 00:00:00.0': 47296.15, '2014-05-13 00:00:00.0': 33047.27, '2014-05-14 00:00:00.0': 25645.86, '2014-05-15 00:00:00.0': 31806.22, '2014-05-16 00:00:00.0': 49846.26, '2014-05-17 00:00:00.0': 29198.83, '2014-05-18 00:00:00.0': 33001.06, '2014-05-19 00:00:00.0': 16558.01, '2014-05-20 00:00:00.0': 43688.15, '2014-05-21 00:00:00.0': 25794.95, '2014-05-22 00:00:00.0': 17414.02, '2014-05-23 00:00:00.0': 25661.97, '2014-05-24 00:00:00.0': 30707.18, '2014-05-25 00:00:00.0': 19127.84, '2014-05-26 00:00:00.0': 26552.53, '2014-05-27 00:00:00.0': 13517.47, '2014-05-28 00:00:00.0': 39338.9, '2014-05-29 00:00:00.0': 25546.25, '2014-05-30 00:00:00.0': 14286.25, '2014-05-31 00:00:00.0': 25137.29, '2014-06-01 00:00:00.0': 39940.35, '2014-06-02 00:00:00.0': 41520.41, '2014-06-03 00:00:00.0': 24381.6, '2014-06-04 00:00:00.0': 24597.44, '2014-06-05 00:00:00.0': 14154.59, '2014-06-06 00:00:00.0': 29931.83, '2014-06-07 00:00:00.0': 36834.15, '2014-06-08 00:00:00.0': 35127.21, '2014-06-09 00:00:00.0': 44563.2, '2014-06-10 00:00:00.0': 16817.27, '2014-06-11 00:00:00.0': 28803.69, '2014-06-12 00:00:00.0': 27426.44, '2014-06-13 00:00:00.0': 39116.97, '2014-06-14 00:00:00.0': 43824.5, '2014-06-15 00:00:00.0': 20881.44, '2014-06-16 00:00:00.0': 35070.53, '2014-06-17 00:00:00.0': 30644.41, '2014-06-18 00:00:00.0': 32682.51, '2014-06-19 00:00:00.0': 47391.75, '2014-06-20 00:00:00.0': 25706.96, '2014-06-21 00:00:00.0': 17196.91, '2014-06-22 00:00:00.0': 23103.45, '2014-06-23 00:00:00.0': 23146.55, '2014-06-24 00:00:00.0': 23427.4, '2014-06-25 00:00:00.0': 37621.4, '2014-06-26 00:00:00.0': 24306.14, '2014-06-27 00:00:00.0': 47910.89, '2014-06-28 00:00:00.0': 22260.18, '2014-06-29 00:00:00.0': 19895.91, '2014-06-30 00:00:00.0': 31446.39, '2014-07-01 00:00:00.0': 28576.8, '2014-07-02 00:00:00.0': 19860.78, '2014-07-03 00:00:00.0': 30640.73, '2014-07-04 00:00:00.0': 17784.68, '2014-07-05 00:00:00.0': 35675.93, '2014-07-06 00:00:00.0': 13465.18, '2014-07-07 00:00:00.0': 24332.8, '2014-07-08 00:00:00.0': 34845.64, '2014-07-09 00:00:00.0': 28610.76, '2014-07-10 00:00:00.0': 30247.47, '2014-07-11 00:00:00.0': 21528.33, '2014-07-12 00:00:00.0': 29528.6, '2014-07-13 00:00:00.0': 29041.92, '2014-07-14 00:00:00.0': 24056.18, '2014-07-15 00:00:00.0': 38500.98, '2014-07-16 00:00:00.0': 32893.29, '2014-07-17 00:00:00.0': 23240.27, '2014-07-18 00:00:00.0': 34192.71, '2014-07-19 00:00:00.0': 32981.55, '2014-07-20 00:00:00.0': 45338.95, '2014-07-21 00:00:00.0': 37885.36, '2014-07-22 00:00:00.0': 24028.45, '2014-07-23 00:00:00.0': 25482.51, '2014-07-24 00:00:00.0': 34552.03}
In [21]:
len(get_daily_revenue(orders, order_items, 'COMPLETE'))
Out[21]:
364
In [22]:
get_daily_revenue(orders, order_items, 'COMPLETE')['2014-07-10 00:00:00.0']
Out[22]:
30247.47