Black Lives Matter. Please consider donating to Black Girls Code today.

To plot a dynamic graph with drop down

Here, is my data-set I’m getting really very confused while coding the drop down for graphs i want my dropdown button to show equipment names and when i click on a particular equipment it should show that particular equipment on graph with the dates and also should show the total number of days between that same equipment
for example if abc is a equipment been greased in moth of feb 19 and that same equipment is been greased in the month of march 19 it should calculate and show mw the total number of days between the same equipment that has been greased
in the data set STOCK means the grease in grams that is used for greasing an equipment
I want Equipment Name, STOCK and Dates

this is what i have code

use_date = widgets.Dropdown(
options=list(df[‘Date’].unique()),
description='Date : ',
value=2019)

eq_name = list(df[‘Equipment Name’].unique())

container = widgets.HBox(children=[use_date])

eq_name = widgets.Dropdown(
options=eq_name,
value=‘WAGON TIPPLER’,

filter_list = [i and j and k for i, j, k in zip(df[‘Date’] == 2019,
df[‘Equipment Name’] == [‘WAGON TIPPLER’])]

Assign an emptry figure widget with two traces

#trace1 = go.Bar(x=df.groupby(by=“Industry”).count()[“Year Month”], name=‘SARs Filings’, orientation=‘v’)
hello= go.Bar(x= df[‘Date’], y=df[‘Equipment Name’])
#trace1 = go.Figure(go.Bar(x = kilndup[‘Equipment Name’] ,y =kilndup[[‘STOCK’]].mean(axis=1) ,
# name=‘EQUIPMENT GREASED’,hovertext=kiln[‘Date’],
# marker_color=‘darkcyan’)
g = go.FigureWidget(data=[trace],
layout=go.Layout(width=600, height=400, font_size=11,
barmode=‘group’,
hovermode=“closest”,
title=dict(
text=‘Greased EQ’
)
))
def response(change):
if validate():
if use_date.value:
filter_list = [i and j and k for i, j, k in zip(df[‘Date’] == use_date.value,
df[‘Equipment Name’] == eq.value)]

    temp_df = df[filter_list]

else:
        filter_list = [i and j for i, j in
                        zip(df['Equipment Name'] == 'WAGON TIPPLER')]
        temp_df = df[filter_list]
    

with g.batch_update():
    g.data[0].x = temp_df['Equipment Name']
    g.data[0].y = temp_df['Date']
    g.layout.xaxis.title = 'SARs Filing Type'
    g.layout.yaxis.title = 'Number of Filings'

origin.observe(response, names=“value”)
reg.observe(response, names=“value”)
use_date.observe(response, names=“value”)

container2 = widgets.HBox([eq_name])
widgets.VBox([container,
container2,g])

This is what my error is

StopIteration Traceback (most recent call last)
~\Anaconda3\lib\site-packages\ipywidgets\widgets\widget_selection.py in findvalue(array, value, compare)
136 try:
–> 137 return next(x for x in array if compare(x, value))
138 except StopIteration:

StopIteration:

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\ipywidgets\widgets\widget_selection.py in _validate_value(self, proposal)
240 try:
–> 241 return findvalue(self._options_values, value, self.equals) if value is not None else None
242 except ValueError:

~\Anaconda3\lib\site-packages\ipywidgets\widgets\widget_selection.py in findvalue(array, value, compare)
138 except StopIteration:
–> 139 raise ValueError(’%r not in array’%value)
140

ValueError: 2019 not in array

During handling of the above exception, another exception occurred:

TraitError Traceback (most recent call last)
in
2 options=list(df[‘Date’].unique()),
3 description='Date : ',
----> 4 value=2019)
5
6

~\Anaconda3\lib\site-packages\ipywidgets\widgets\widget_selection.py in init(self, *args, **kwargs)
188 kwargs[‘label’], kwargs[‘value’] = options[0] if nonempty else (None, None)
189
–> 190 super(_Selection, self).init(*args, **kwargs)
191 self.initializing_traits = False
192

~\Anaconda3\lib\site-packages\ipywidgets\widgets\widget.py in init(self, **kwargs)
410 “”“Public constructor”""
411 self._model_id = kwargs.pop(‘model_id’, None)
–> 412 super(Widget, self).init(**kwargs)
413
414 Widget._call_widget_constructed(self)

~\Anaconda3\lib\site-packages\traitlets\traitlets.py in init(self, *args, **kwargs)
998 else:
999 # passthrough args that don’t set traits to super
-> 1000 super_kwargs[key] = value
1001 try:
1002 super(HasTraits, self).init(*super_args, **super_kwargs)

~\Anaconda3\lib\contextlib.py in exit(self, type, value, traceback)
117 if type is None:
118 try:
–> 119 next(self.gen)
120 except StopIteration:
121 return False

~\Anaconda3\lib\site-packages\traitlets\traitlets.py in hold_trait_notifications(self)
1120 self._trait_values.pop(name)
1121 cache = {}
-> 1122 raise e
1123 finally:
1124 self._cross_validation_lock = False

~\Anaconda3\lib\site-packages\traitlets\traitlets.py in hold_trait_notifications(self)
1106 for name in list(cache.keys()):
1107 trait = getattr(self.class, name)
-> 1108 value = trait._cross_validate(self, getattr(self, name))
1109 self.set_trait(name, value)
1110 except TraitError as e:

~\Anaconda3\lib\site-packages\traitlets\traitlets.py in _cross_validate(self, obj, value)
597 if self.name in obj.trait_validators:
598 proposal = Bunch({‘trait’: self, ‘value’: value, ‘owner’: obj})
–> 599 value = obj.trait_validators[self.name](obj, proposal)
600 elif hasattr(obj, '
%s_validate’ % self.name):
601 meth_name = '
%s_validate’ % self.name

~\Anaconda3\lib\site-packages\traitlets\traitlets.py in call(self, *args, **kwargs)
905 “”“Pass *args and **kwargs to the handler’s function if it exists.”""
906 if hasattr(self, ‘func’):
–> 907 return self.func(*args, **kwargs)
908 else:
909 return self._init_call(*args, **kwargs)

~\Anaconda3\lib\site-packages\ipywidgets\widgets\widget_selection.py in _validate_value(self, proposal)
241 return findvalue(self._options_values, value, self.equals) if value is not None else None
242 except ValueError:
–> 243 raise TraitError(‘Invalid selection: value not found’)
244
245 @observe(‘value’)

TraitError: Invalid selection: value not found

Now I have edited my code here it is

use_date = widgets.Dropdown(
options=list(df[‘Date’].unique()),
description='Date : ',)

eq_name = list(df[‘Equipment Name’].unique())

container = widgets.HBox(children=[use_date])

eq_name = widgets.Dropdown(
options=eq_name,

            description='Equipment Name :')

filter_list = [i and j for i, j in zip(df[‘Date’] == use_date.value,
df[‘Equipment Name’] == eq_name.value)]

can anyone help me out