Saturday 26 September 2020

I want to make 2 drop menu & 1 slide bar at jupyter notebook

I have a dataframe that contains the category of the item, item_id, the sales of all days and the total sales of each product(sum(axis=1)).

The next 4 dataframes have 2 columns item_id and sales depending on the category and their name is household_sort,hobbies_sort,foods_sort and sales_total that includes the total sales of each product.

I want to create 3 dependent widgets (2 drop menu and 1 slide bar) at jupyter notebook.First i want a drop menu about some categories of prducts (for example sales of foods) which are defined in dictionary cat in the code below.After a slidebar where the user will specify the limits of total sales from the category of th first drop menu.Finally drop menu with item id according to the previous I tried this code but i cant change the values of the second drop menu.

from ipywidgets import interact, Dropdown
import ipywidgets as wg
range_slider=wg.IntRangeSlider(value=[1000,10000],min=sales_total['total'].min() - 5,max=sales_total['total'].max() + 5,description='Test:',readout_format='d')

cat={'HOBBIES_SALES':hobbies_sort[(hobbies_sort['total']>= range_slider.value[0]) & (hobbies_sort['total']<=range_slider.value[1])]['item_id'],
     'HOUSEHOLD_SALES':household_sort[(household_sort['total']>= range_slider.value[0]) & (household_sort['total']<=range_slider.value[1])]['item_id'],
     'FOODS_SALES':foods_sort[(foods_sort['total']>= range_slider.value[0]) & (foods_sort['total']<=range_slider.value[1])]['item_id'],
     'TOTAL_SALES':sales_total[(sales_total['total']>=range_slider.value[0]) & (sales_total['total']<=range_slider.value[1])]['item_id']}
catW=Dropdown(options=cat.keys())
idW=Dropdown(options=cat[catW.value])

    
display(catW,range_slider,idW)


from I want to make 2 drop menu & 1 slide bar at jupyter notebook

No comments:

Post a Comment