How to do these extraction/computations efficiently?
In general if you have relational data in a list-like data structure, you want to convert it into a more appropriate data structure before you do anything tricky with it.  I'm not sure what the type of recipes_df so I'm just going to copy your code that iterates over it and go from there.

from collections import defaultdict
from typing import Dict, List, Set, Tuple

# For each product, return where it can be produced.
product_lines: Dict[str, Set[str]] = defaultdict(set)

# For each line, what are the products that it can produce.
line_products: Dict[str, Set[str]] = defaultdict(set)

# For each (p,l) couple store the set of all need raw materials 
# to produce product p on l, the property of each raw material
# (coded as 1 if it's S and 0 otherwise), and the total price
class Recipe:
    def __init__(self):
        self.raw_materials: List[Tuple[str, int]] = []
        self.total_price = 0.0
recipes: Dict[Tuple[str, str], Recipe] = defaultdict(Recipe)

# Loop over recipes_df and populate all these structures.
for product, line, rm, rm_type, rm_price in \
        recipes_df[['product','line', 'rm','rm_type','rm_price']].values:
    product_lines[product].add(line)
    line_products[line].add(product)
    recipes[(product, line)].raw_materials.append((rm, 1 if rm_type == 'S' else 0))
    recipes[(product, line)].total_price += rm_price


At this point you've done a single pass through the entirety of recipes_df and you've completely populated the dictionaries that will let you find all the information you're looking for in constant time.  From here you can convert those dictionaries into whatever other output format you need.