title: Create a drop-down list based on the unique values in the column and assign the selected value to the variable
body: <p>I have a huge dataframe:</p>
  
  <pre><code>              df
   code_1     code_2    code_3
  065.0055     3315      N-W
  067.3355     4511      S-E
  065.0055     3315      N-W
  034.0035     4511      N-W
  067.3355     1311      S-E
  ...
  </code></pre>
  
  <p>In the original dataframe, there are several columns and a large number of rows.</p>
  
  <p>I need to find unique values in the columns <code>code_1</code>, <code>code_2</code>, <code>code_3</code>, then create a drop-down list and assign the selected value to a specific variable. And I need to do this for each column separately.</p>
  
  <p>For example, I find all the unique values in a column <code>code_1</code> , the user selects the desired value from the drop-down list (for example <code>065.0055</code>) and this value is assigned to the variable(<code>vl = '065.0055'</code>).</p>
  
  <p>I need to assign the chosen values to the variable, so that I can continue to make calculations based on them.</p>
  
  <p>I found how to create a drop down list, but I do not know how to assign the selected value(as in the example with <code>vl</code>)</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import ipywidgets as widgets
  from IPython.display import display
  from IPython.html.widgets import interactive
  
  items = ['-']+sorted(df['code_1'].unique().tolist())
  
  def view(x=''):
      if x=='-':
          return df
      return df[df['code_1']==x]
  
  w = widgets.Select(options=items)
  interactive(view, x=w)
  </code></pre>
  
  <p>As a result, I need to get three variables, for example:
  If the user made the following choice: from <code>code_1</code> was chosen <code>065.0055</code>, from <code>code_2</code> was chosen <code>3315</code>, from <code>code_3</code> was chosen <code>S-E</code>. </p>
  
  <p>I need to get three variables</p>
  
  <pre><code>vl1 = '065.0055'
  vl2 = '3315'
  vl3 = 'S-E'
  </code></pre>
  
  <p>I need advice, please!</p>
  
  <p><strong>UPD</strong> After studying a few questions, I decided to try using <code>Tkinter</code>
  Here is my code:</p>
  
  <pre><code>items = ['-']+sorted(df['code_1'].unique().tolist())
  items1 = ['-']+sorted(df['code_2'].unique().tolist())
  items2 = ['-']+sorted(df['code_3'].unique().tolist())
  
  from tkinter import*
  
  class MyOptionMenu(OptionMenu):
      def __init__(self, master, status, *options):
          self.var = StringVar(master)
          self.var.set(status)
          OptionMenu.__init__(self, master, self.var, *options)
          self.config(font=('calibri',(10)),bg='white',width=12)
          self['menu'].config(font=('calibri',(10)),bg='white')
  
  root = Tk()
  optionList = items
  optionList1 = items1
  optionList2 = items2
  mymenu1 = MyOptionMenu(root, 'Select code_1', *optionList)
  mymenu2 = MyOptionMenu(root, 'Select code_2', *optionList1)
  mymenu3 = MyOptionMenu(root, 'Select code_3', *optionList2)
  mymenu1.pack()
  mymenu2.pack()
  mymenu3.pack()
  root.mainloop()
  </code></pre>
  
  <p>How can I save the result of the selection to a variables?</p>