Alex Martinelli
1 min readOct 2, 2017

--

Thanks John!

And yes, working now on polishing some of the code for then posting it on Github.

Regarding your question, the problem is that interact is not returning your object, but a function. So what I suggest is to update the caption value inside the method called by interact.

def get_nutritional_info(db, food, nutrient):
food_info = db
# filter by food
# consider each words separately for filtering
for word in food.split():
food_info = food_info[food_info['Food'].str.contains(word)]
# filter by nutrition
nutritional_info = food_info[food_info['Nutrient']==nutrient]
# Use this for printing directly
print("I found {} results".format(len(nutritional_info)))
# or this to update your externally defines caption
caption.value = str(len(nutritional_info))
return nutritional_info

This is an example for the database I have, but should give you an idea on how to work for your case.

--

--

Alex Martinelli

Data Scientist @ Zalando Dublin - Machine Learning, Computer Vision and Everything Generative ❤