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