recipebox_pkg package
Submodules
recipebox_pkg.fetch_recipe module
- recipebox_pkg.fetch_recipe.convert_recipes(response)[source]
Convert recipe information from Spoonacular API response to a styled DataFrame.
Parameters: - response (dict): The response from the Spoonacular API containing recipe information.
Returns: - pd.io.formats.style.Styler: A styled DataFrame with selected columns and formatted ‘sourceUrl’ column.
- recipebox_pkg.fetch_recipe.search_recipes(api_key, query, r_diet=None, r_excludeIngredients=None, r_intolerances=None, r_number=10)[source]
Search for recipes based on a specified query and additional parameters using the Spoonacular API.
Parameters: - api_key (str): The API key for accessing the Spoonacular API. - query (str): The search query for recipes. - r_diet (str): The diet type to filter recipes (e.g., ‘vegetarian’, ‘vegan’). - r_excludeIngredients (str): Ingredients to exclude from the recipes. - r_intolerances (str): Intolerances to consider when searching for recipes. - r_number (int): The maximum number of recipes to retrieve (default is 10).
Returns: - dict or None: A dictionary containing recipe information or None if an error occurs.
recipebox_pkg.id_search module
- class recipebox_pkg.id_search.Recipe_id(id, api_key)[source]
Bases:
object- convert_instruction(list_in)[source]
Convert and print a list of instruction steps.
Parameters: - list_in (list): List of instruction steps.
Returns: - None
- dict_reader(input_dict)[source]
Process a dictionary into a Pandas Series.
Parameters: - input_dict (dict): The input dictionary to process.
Returns: - pd.Series: Processed Pandas Series.
- list_reader(input_dict)[source]
Process a dictionary into a Pandas Series.
Parameters: - input_dict (dict): The input dictionary to process.
Returns: - pd.Series: Processed Pandas Series.
- search_equipment_id()[source]
Fetch equipment information for a recipe using the Spoonacular API.
Returns: - pd.DataFrame or None: A DataFrame containing equipment information or None if an error occurs.
- search_ingredient_id()[source]
Search for ingredient information using the Spoonacular API.
Returns: - pd.DataFrame or None: A DataFrame containing ingredient information or None if an error occurs.
- search_instruction_id()[source]
Fetch analyzed instructions for a recipe using the Spoonacular API.
Returns: - list or str: A list of instruction steps or an error message if no instructions are found or an error occurs.
- search_nutrient_id(selection='info')[source]
Fetch nutrition information for a recipe using the Spoonacular API.
Parameters: - selection (str, optional): Type of nutrition information to retrieve.
‘info’: General information about nutrients, caloric breakdown, and weight per serving.
‘table’: Detailed table of nutrient information.
Returns: - pd.DataFrame: A DataFrame containing the requested nutrition information.
recipebox_pkg.ing_search module
- recipebox_pkg.ing_search.display_images_ingredients(df)[source]
Display images for each recipe in a DataFrame.
Parameters: - df (pd.DataFrame): DataFrame containing recipe information, including ‘title’, ‘id’, and ‘image’ columns.
This function iterates over the DataFrame, printing the title and recipe ID for each row, and then displays the corresponding image.
Example: >>> df = pd.DataFrame({‘title’: [‘Spaghetti Carbonara’, ‘Chicken Alfredo’], … ‘id’: [123, 456], … ‘image’: [’https://example.com/spaghetti.jpg’, ‘https://example.com/chicken.jpg’]}) >>> display_images_ingredients(df)
- recipebox_pkg.ing_search.ingredient_search_recipe(api_key, ingredient_list, number=5)[source]
Search for recipes based on specified ingredients using the Spoonacular API.
Parameters: - api_key (str): The API key for accessing the Spoonacular API. - ingredient_list (list): List of ingredients to search for in recipes. - number (int): The maximum number of recipes to retrieve (default is 5).
Returns: - pd.DataFrame or None: A DataFrame containing recipe information or None if no recipes are found.
recipebox_pkg.nutr_search module
- recipebox_pkg.nutr_search.display_images_nutrient(recipe_df)[source]
Display nutrient information and images for each recipe in a DataFrame.
Parameters: - recipe_df (pd.DataFrame): DataFrame containing recipe information, including ‘title’, ‘id’, ‘calories’, ‘protein’, ‘fat’, ‘carbs’, and ‘image’ columns.
This function iterates over the DataFrame, printing the title, recipe ID, and nutrient information for each row, and then displays the corresponding image.
Example: >>> df = pd.DataFrame({‘title’: [‘Spaghetti Carbonara’, ‘Chicken Alfredo’], … ‘id’: [123, 456], … ‘calories’: [500, 700], … ‘protein’: [20, 30], … ‘fat’: [15, 25], … ‘carbs’: [50, 40], … ‘image’: [’https://example.com/spaghetti.jpg’, ‘https://example.com/chicken.jpg’]}) >>> display_images_nutrient(df)
- recipebox_pkg.nutr_search.nutrient_search_recipe(api_key, nutrients)[source]
Search for recipes based on specified nutrient parameters using the Spoonacular API.
Parameters: - api_key (str): The API key for accessing the Spoonacular API. - nutrients (dict): Dictionary containing nutrient parameters for the recipe search.
Returns: - pd.DataFrame or None: A DataFrame containing recipe information or None if no recipes are found.