I have the following code to create a dasboard. It works fine. I mean it produces the plots and figures.
wgt_schoolSelected = pn.widgets.Select(name='Okul Seçiniz:', options=list(classSchool.Name.unique()))
nQuestionsPerExam = pn.widgets.IntSlider(name='Min. Sinav Soru Sayisi', start=0, end=20, step=5, value=5)
# Visualization function that updates based on widget selections
@pn.depends(wgt_schoolSelected, nQuestionsPerExam)
def VisualizeSchoolSube(schoolVal, nQuestion):
#number of students per each gradelevel for the selected school.
df_school = classSchool[classSchool.Name == schoolVal]
df = df_school.groupby('GradeLevel').size().to_frame().rename(columns={0:'Count'})
bar_studentCountByGrade = df.hvplot.bar(alpha=0.5, width=400,
line_width=0, color="#e5ae38", label="Öğrenci Sayisi")
return bar_studentCountByGrade
wgt_gradeLevel= pn.widgets.Select(name='Kaçıncı Sınıf:', options=list(range(5, 13)))
@pn.depends(wgt_schoolSelected, nQuestionsPerExam, wgt_gradeLevel)
def VisualizeGradeLevel(schoolVal, nQuestion, gradeLevel):
df = examTakes[examTakes.Name == schoolVal]
df = df[df.GradeLevel == gradeLevel].groupby('ExamType')[['ExamId']].count().rename(columns={'ExamId':'count'})
examTypeCount_plot = df.hvplot.bar(alpha=0.5, width=400,
height=400, line_width=0,
color="#A1C7E0", label="Sınav Türü : ").opts(xrotation=45)
return examTypeCount_plot
pn.Column(
pn.Row(
pn.Column(pn.WidgetBox("Seçenekler", wgt_schoolSelected, nQuestionsPerExam), VisualizeSchoolSube)
),
pn.Row(
pn.Column(pn.WidgetBox("Seçenekler", wgt_gradeLevel), VisualizeGradeLevel),
)
)
However, whenever a different item is selected from wgt_schoolSelected
, it outputs an error (although the plots are updated properly). I have tried many things since yesterday but still receiving the same error. Interestingly, the same error message block is displayed four times consecutively under each other. I also could not find any related posts about this. I appreciate any help.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File ~\AppData\Roaming\Python\Python39\site-packages\jupyter_bokeh\widgets.py:128, in BokehModel._sync_model(self, _, content, _buffers)
126 new, old, attr = content["new"], content["old"], content["attr"]
127 submodel = self._model.select_one({"id": content["id"]})
--> 128 descriptor = submodel.lookup(content['attr'])
129 try:
130 descriptor._set(submodel, old, new, hint=hint, setter=self)
AttributeError: 'NoneType' object has no attribute 'lookup'