Issue
This code is a "Filter as you type" textbox example. It works fine on Google Colab, but not on Jupyter Notebook. I tried it on 2 different computers (and on 2 different browsers) that have Jupyter Notebook installed and the 'out' widget only displays the textbox but nothing else. Any idea how to fix this?
I have tried pip uninstall ipywidgets then install again without success.
Thanks.
import pandas as pd, IPython.display, ipywidgets as widgets
out = widgets.Output()
df = pd.DataFrame ({'PLAYER':['MOHAMED SALAH', 'MESSI', 'MO SALAH', 'RONALDO', 'PELE', 'PEPE', 'MANE', 'RAMREZ']})
textbox = widgets.Text(value='', description='Player:')
display(textbox)
def display_result(value):
value = str(value['new']).upper()
if "{" not in value:
result = df[(df['PLAYER'].str.contains(value))]
if result.shape[0]>0:
with out:
out.clear_output()
display(result)
display(out)
textbox.observe(display_result)
This is the output from Google Colab:
This is the output from Jupyter Notebook:
Solution
I have discovered that this is caused by the "Limit Output" extension in NbExtensions. When I disabled it, the output widget worked.
Answered By - PythonDyson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.