<jupyter_start><jupyter_text>If we want to do a reverse lookup so that we can see which recipes use a piece of equipment, we can do that here:<jupyter_code>def row_contains(row, values_to_look_for):
    values_in_row = list(row[1:])
    for v in values_to_look_for:
        it_does = v in values_in_row
        if it_does:
            return it_does
    return False

on_hand = ['Sieve']
uses = equipment.apply(lambda x: row_contains(x, on_hand), axis=1)
these_recipes = equipment[uses]
list(these_recipes["title"])<jupyter_output><empty_output><jupyter_text>Which bit of kit gets used in the most recipes?<jupyter_code>counts = {}

for thing in messy_uniques:
    on_hand = [thing]
    uses = equipment.apply(lambda x: row_contains(x, on_hand), axis=1)
    these_recipes = equipment[uses]
    counts[thing] = {"count": these_recipes.shape[0], "recipes": list(these_recipes["title"])}
    

c = pd.DataFrame.from_dict(counts, orient="index")
c.sort_values(by=['count'], ascending=False, inplace=True)
c[c["count"]>1]
list(c.index)
raw = ['2 heavy-bottomed pots', '2 large pots', '3 springform pans 9″ (23 cm)', 'AeroPress', 'Aerolatte', 'Aluminum foil', 
       'An eager and positive attitude', 'Axes', 'Baking sheets', 'Bamboo steamer', 'Binder clip', 'Blender', 'Brine injector', 
       'Broiler', 'Bucket glass', 'Butcher’s twine', 'CO₂ cartridges', 'Cambro (2 qt)', 'Candy thermometer', 'Canelé molds', 
       'Canning jars', 'Cast iron pan', 'Centrifuge bottles', 'Chamber sealer packaging', 'Cheesecloth', 'Chef knife', 
       'Chocolate mold', 'Chopsticks', 'Cocktail glasses', 'Cocktail shaker', 'Cocktail stirring glass', 'Cocktail strainer', 
       'Coffee filter', 'Coffee grinder', 'Cupcake pan', 'Cutting board', 'Deep tart pan or springform pan', 'Dehydrator', 
       'Digital scale', 'Digital thermometer', 'Dish washing sponge', 'Dough cutter', 'Fine-tipped squeeze bottle(s)', 
       'Fish pliers', 'Flat-bowled soup spoon', 'Food processor or blender', 'Food-grade silica packs', 'Freezer', 
       'French press', 'Fridge', 'Glass jar with lid', 'Grill', 'Hardwood Charcoal', 'Heat', 'Heavy-bottomed pot', 
       'Hemisphere silicone mold', 'High-precision digital scale', 'ISi whipping siphon or air compresser', 'Ice cream maker', 
       'Icing comb', 'Immersion blender', 'Juicer', 'Ladle', 'Large bowl', 'Large pot', 'Lighter or matches', 
       'Loaf pan (5.75 x 3 x 2 in)', 'Long Honing Rod', 'Mandoline', 'Meat tenderizer', 'Microplane', 'Microwave', 
       'Muslin cloth', 'Needle-nose pliers', 'None', 'Nonstick pan', 'N₂O cartridges', 'Offset spatula', 
       'One quart-sized mason jar', 'Paper towels', 'Parchment paper', 'Pastry brush', 'Peeler', 'Petty knife', 
       'Pint-sized mason jars', 'Piping bag', 'Piping tip', 'Plastic wrap', 'Pot', 'Pressure cooker', 
       'Quart-sized canning jars', 'Refractometer', 'Ring molds', 'Ring mold 3″ diameter', 'Ring mold, 3.5″ diameter', 
       'Ring mold, 3″ diameter', 'Ring mold, 4″ (105 mm) diameter', 'Rolling pin', 'Round piping tip', 'Saucepan', 'Scissors', 
       'Sharp knife', 'Sharpening Stones Kit', 'Silicone mold', 'Silpats', 'Slicing knife', 'Slotted spoon', 'Small pot', 
       'Smoker', 'Soup cans or other weights', 'Sous vide bag(s)', 'Spatula', 'Spherification straining spoon', 
       'Spider strainer', 'Spoon', 'Spray bottle', 'Springform pan 9″', 'Stainless steel pans', 'Strainer', 'Syringe', 
       'Tea strainer', 'Thermocouple thermometer', 'Tiny scissors', 'Tongs', 'Toothpicks', 'Tupperware', 'Tweezers', 
       'Vacuum sealer bags', 'Whipping siphon', 'Whisk', 'Wide-mouth canning jars', 'Wooden spoon', 'Ziplock-style bags', 
       'Ziplock-style bags (1 gallon)', 'Ziplock-style bags (2 gallon)', 'mason jars (4 oz)', 'mason jars (8 oz)', 
       'stockpot (8 qt)','3 springform pans, 9″ (23 cm)', 'Gooseneck kettle', 'Ring cutter, 1.5″', 'Cake pan, black, 9″',
       'Rubber gloves' ]
i_have = list(set([fold(x) for x in raw]))
# print(len(raw), len(i_have))
str(sorted([str(x) for x in i_have]))
sorted([str(x) for x in i_have])
ones  = []
mores = []
everything = []
more_to_get = []
for i, r in equipment.iterrows():
    this_recipe_needs = set(list(r)[1:-1])
    recipe_title = list(r)[0]
#     if this_recipe_needs.issubset(i_have):
#         print(recipe_title)
#         print(this_recipe_needs)
    needs = []
    for item in this_recipe_needs:
        if item != '' and item != ' ': 
            if item not in i_have:
                needs.append(item)
    if len(needs) == 0:
        print("Got everything you need for", recipe_title)
        everything.append(recipe_title)
    else:
        print(recipe_title, 'needs:\n   ', needs)
        more_to_get.append(recipe_title+str(needs))
        if len(needs) == 1:
            ones.extend(needs)
        else:
            mores.extend(needs)
everything
more_to_get
from collections import Counter
Counter(ones).most_common()
Counter(mores).most_common()
# area under the curve

# constrained by resourses, what should I buy If I had 5k?

#explore with a ga?

#<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15069840645288216, 'fraction_numerical': 0.008656305331497147, 'mean_word_length': 4.023715415019763, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '434827', 'license': 'MIT', 'n_tokens_mistral': 1852, 'n_tokens_neox': 1712, 'n_words': 522, 'path': 'Data cleanup.ipynb', 'repo_name': 'notionparallax/ChefstepsEquipment', 'size': '5083'}