Tuesday 20 December 2016

Which Really Useful Boxes stack?

Which Really Useful Boxes stack together?

"Really Useful Boxes" are great. They come in lots of sizes and are used everywhere. The sales literature gives examples of what you can store in them.

But which sizes stack exactly on top of each other?

The list below shows the boxes that stack, grouped by those with the most common size.
(Scroll down for the Python script that was used to group the data).


Length Width (mm)                     Box Name
----------------------------------------------
    395   255     4 litre Really Useful Box (ream of A4)
    395   255     9 litre Really Useful Box (ream of A4)
    395   255     9 litre XL Really Useful Box (7" small)
    395   255    14 litre open front Really Useful Box (shoes)
    395   255    19 litre Really Useful Box (A4 paper)
    395   255    19 litre XL Really Useful Box (LP small)
    395   255    25 litre Really Useful Box (12" x 12")
----------------------------------------------
    710   440    20 litre Really Useful Box (board games)
    710   440    33 litre Really Useful Box 
    710   440    50 litre Really Useful Box
    710   440    64 litre Really Useful Box
    710   440    64 litre open front Really Useful Box
    710   440    84 litre Really Useful Box
----------------------------------------------
    340   200     2.5 litre Really Useful Box
    340   200     5 litre Really Useful Box
    340   200     5 litre XL Really Useful Box
    340   200     8 litre open front Really Useful Box
----------------------------------------------
    480   390    18 litre Really Useful Box
    480   390    18 litre XL Really Useful Box (7" medium)
    480   390    35 litre Really Useful Box
    480   390    35 litre XL Really Useful Box (LP medium)
----------------------------------------------
    600   400    24.5 litre Really Useful Box
    600   400    48 litre Really Useful Box
    600   400    48 litre XL Really Useful Box
----------------------------------------------
    465   270     6 litre Really Useful Box
    465   270    12 litre Really Useful Box
    465   270    24 litre Really Useful Box
----------------------------------------------

The following boxes only have one 'partner in size':

Length Width (mm)                     Box Name
----------------------------------------------
    090   065    0.07 litre Really Useful Box
    090   065    0.14 litre Really Useful Box
----------------------------------------------
    120   085    0.2 litre Really Useful Box
    120   085    0.3 litre Really Useful Box
----------------------------------------------
    155   100    0.35 litre Really Useful Box
    155   100    0.7 litre Really Useful Box
----------------------------------------------
    195   135    0.75 litre Really Useful Box
    195   135    1.6 litre Really Useful Box
----------------------------------------------
    220   100    0.55 litre Really Useful Box
    220   100    0.9 litre Really Useful Box
----------------------------------------------
    245   180    1.75 litre Really Useful Box
    245   180    3 litre Really Useful Box
----------------------------------------------
    355   100    0.8 litre Really Useful Box
    355   100    1.5 litre Really Useful Box
----------------------------------------------
    450   350   21 litre Really Useful Box
    450   350   21 litre XL Really Useful Box
----------------------------------------------
    456   356   11 litre Really Useful Box
    455   356   11 litre XL Really Useful Box
----------------------------------------------
    810   620   70 litre Really Useful Box
    810   620  145 litre Really Useful Box
----------------------------------------------

The following boxes don't stack exactly with any other sized box.

    180   135    1.7 litre folding Really Useful Box
    240   130    2.1 litre Really Useful Box
    430   180    6.5 litre Really Useful Box
    400   350    7 litre Really Useful Box
    520   340   10 litre Really Useful Box
    820   255   22 litre Really Useful Box
    470   342   32 litre folding Really Useful Box
    485   390   35 litre folding Really Useful Box
    520   440   42 litre Really Useful Box
    390   570   45 litre folding Really Useful Box
   1201   270   77 litre Really Useful Box


The Python Script

This section is intended for those interested in how the data was prepared.

The data comes from the table here, and was copied-and-pasted into a text file. The top line was edited to make a tab-separated header row.

The python script was written as an exercise in using Pandas Dataframes. The goal was to read the file, parse, sort, and filter, then group the boxes on external length and width. Although this could have been done manually on this dataset (59 rows), the manual approach does not scale to larger datasets.

Here is the script.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
 Parse the sizes of ReallyUsefulBoxes and group them by external dimension.
'''

import pandas as pd

filename = 'ReallyUsefulBoxesRaw.txt'
list_data = pd.read_csv(filename, sep='\t')
# force a rename of the columns
list_data.columns = ['BoxName','Extl','Intl','Wt']

# ---extract external dimension data into 3 new DataFrame columns:
extList = list_data['Extl'].str.split(' x ')
list_data['Length'] = [row[0] for row in extList]
list_data['Width'] = [row[1] for row in extList]
list_data['Height'] = [row[2] for row in extList]

# Just use the columns of interest
trimmed_data = list_data[['Length','Width','BoxName']]
grouped_data = trimmed_data.groupby(['Length','Width'])
#print grouped_data

# Print out each group: these are the boxes that have the same width and
# height and therefore stack together.
for name, group in grouped_data:
    print '\n------------',name,'------------'
    print(group)

If you found this useful, please leave a comment or share this blog with others.