Bootstrap clarification for datasets with multiple columns
Here you have an example on how to carry out a bootstrap selection from any given set of data, based on (as you suggested) using loops and randomly selecting indexes to recreate a simulated new bag from the whole population of M&amp;Ms. The criteria should be pretty the same for different kind of data, since what you actually do is simulate the selection of samples from a population.
It could be something like:
-bags you have from different factories:
bag_1 = ['blue']*15 + ['red']*15 + ['green']*10 + ['orange']10
bag_2 = ['blue']*14 + ['red']*16 + ['green']*9 + ['orange']*11
bag_3 = ['blue']*16 + ['red']*15 + ['green']*11 + ['orange']*8

-color distributions per bag:
import seaborn as sns
import pandas as pd

bags_df = pd.DataFrame({'bag': [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3], 
                     'color': ['blue','red', 'green', 'orange', 'blue','red', 
                     'green', 'orange', 'blue','red', 'green', 'orange'], 
                     'count': [15, 15, 10, 10, 14, 16, 9, 11, 16, 15, 11, 8]})

ax = sns.barplot(x=&quot;bag&quot;, y=&quot;count&quot;, hue=&quot;color&quot;, data=bags_df)


-now your population would be all the bags together inb a big bag:
super_bag = bag_1+bag_2+bag_3

-and here is where you do the actual bootstrap:
### GENERATE 10 BOOTSTRAPED BAGS 
from numpy.random import seed, rand, randint, randn

# seed random number generator
seed(1)

bootstrap_bags_dict = {}
for i in range(10):
    bootstrap_bags_dict['sub_bag_'+str(i)] = []
    # bootstrap sample
    boots_indices = randint(0, 50, 25)
    for idx in boots_indices:
        bootstrap_bags_dict['sub_bag_'+str(i)].append(super_bag[idx])

and you get a dictionary with 10 bags like:

In case you want to see if there is any difference in, for instace, the red color distribution coming from factory 1 or 2, I would:

split the dataset by factory1 and factory2, get the red M&amp;Ms count for each one
then shuffle all the M&amp;Ms in a big bag as coming from the same factory; here, your initial hypothesis is that there is no difference in receiving red M&amp;Ms from both factories
as explained here , you can compare by permutation and hypothesis testing if the difference between bootstrapped samples from your big bag (as considering both bags from the same factory) is statistically different compared to the difference between the 2 initial factories bags (it might sound hard to know, some code about it can be provided)