Calculate food nutrients (food)
This calculator function helps you calculate the nutrients in your food. Just enter the food items and get the nutrient information.
Calculate food nutrients
Purpose
The purpose of this function is to calculate and return the nutrient information of various foods based on user input.
Use Cases
- Users can input the names of different foods to retrieve their nutrient information.
- Users can specify if they want information for branded foods only.
- Users can set a minimum percentage match for the food names.
How to Use
- Enter the names of the foods you want to calculate the nutrients for.
- Optionally, specify if you only want information for branded foods.
- Set a minimum percentage match for the food names.
- Click on the 'Calculate' button to retrieve the nutrient information.
Input Values
- Search Foods: Names of the foods you want to calculate the nutrients for.
- Description: Enter the names of the foods separated by commas.
- Branded: Select if you only want information for branded foods.
- Description: Check the box if you want to include only branded foods.
- Percent Match: Set a minimum percentage match for the food names.
- Description: Enter a percentage value to filter the food names.
Output Values
- Nutrient Data: Nutrient information of the selected foods.
- Description: The function will return a table containing nutrient information such as calories, protein, fat, etc.
Any other Instruction
- Make sure to enter the correct names of the foods for accurate results.
- Adjust the percentage match to refine the search results.
Calculation Steps
- Retrieve the Food Data Collection IDs (fdcIDs) based on the input food names.
- If fdcIDs are found, retrieve the nutrient information using the fdcIDs.
- Return the nutrient information in a table format.
Technical Parameters
- search_foods, separator, branded, percent_match
Return Values
- nutrient_df
Example Expressions
You can use the following expressions to directly evaluate in a non-interactive manner using eval():
- Calculate nutrients for apples and oranges:
food('apple, orange')
- Calculate nutrients for branded foods with a minimum 70% match:
food('apple, orange', branded=True, percent_match=70)
Click on Help icon to open the help page on a separate window.