title: Tkinter Pandas Python App - Not Getting Value and Performing Calculation
body: <p>I'm fairly new to Python/Pandas/Tkinter and I'm attempting to build a tkinter application that can receive numerical inputs and then perform a WAC (weighted average coupon rate) calculation based on the given input.</p>
  <p><a href="https://i.stack.imgur.com/zHt87.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zHt87.png" alt="enter image description here" /></a></p>
  <p>I bring in a dataset via pandas dataframe with three columns - Original Amount, Loan Rate and Special Project Code. I then create a new column, Rate Weight, that is the product of the Original Amount and Loan Rate columns.</p>
  <p>The purpose of the app is to receive input from a user for a certain code value that changes the row values in the Loan Rate column based on what interest rate input they give, then a new WAC calculation is performed and shown. So far I only have one input box for one code, code 3231 (not shown above in the sample image).</p>
  <p>When I run the app and input a numerical value in the box and click 'Calculate WAC' it returns the   normal WAC value of the dataset, but not a WAC value performed with the new interest rate for code 3231. It seems to me I'm not capturing the value for the rate and properly and replacing the old with the new.</p>
  <pre><code>from tkinter import *
  from random import randint
  import pandas as pd
  
  root = Tk()
  root.title(&quot;Financing Grid&quot;) 
  root.geometry(&quot;600x600&quot;)
  
  
  global df
  
  df = pd.read_excel(&quot;C:\\Users\\mhorv656\\Documents\\Financing Grid v4.xlsx&quot;, &quot;Data&quot;,
      engine = 'openpyxl', usecols = ['ORIG_AMT', 'LOAN_RATE', 'SPECIAL_PROJ_CD'])
  
  df['ORIG_AMT'] = df['ORIG_AMT'].fillna(0).astype(int)
  df[&quot;Rate_WT&quot;] = df[&quot;ORIG_AMT&quot;] * df[&quot;LOAN_RATE&quot;]
  df['SPECIAL_PROJ_CD'] = df['SPECIAL_PROJ_CD'].fillna(0).astype(int)
  
  
  # Codes 
  def c3231_code():
      c3231_frame.pack(fill = &quot;both&quot;, expand = 1)
  
      # Creating Input Box
      global c3231_input
      #c3231_input = IntVar()
      c3231_input = Entry(c3231_frame)
      c3231_input.pack(pady = 5)
  
      # Creating Answer Button
      c3231_button = Button(c3231_frame, text = &quot;Calculate WAC&quot;, command = c3231_wac)
      c3231_button.pack(pady = 5)
  
      # Creating Correct or Incorrect Message
      global c3231_label
      c3231_label = Label(c3231_frame, text = &quot;Enter Rate Above&quot;)
      c3231_label.pack(pady = 5)
  
  
  def c3231_wac():
      df.loc[df['SPECIAL_PROJ_CD'] == '3231', 'LOAN_RATE'] = int(c3231_input.get())
      
      WAC = df[&quot;Rate_WT&quot;].sum() / df[&quot;ORIG_AMT&quot;].sum()
      WAC_label = Label(c3231_frame, text = WAC)
      WAC_label.pack(pady = 5)
  
      # Clearing the answer box
      c3231_input.delete(0, 'end')
  
  
  
  # Creating a Hide Frame Function
  def hide_menu_frames():
      # Destroying the children widgets in each frame
      for widget in c3231_frame.winfo_children():
          widget.destroy()
  
  
      # Hiding all frames
      c3231_frame_frame.pack_forget()
  
      start_frame.pack_forget()
  
  # Creating Frames
  c3231_frame = Frame(root, width = 400, height = 400)
  start_frame = Frame(root, width = 400, height = 400)
  
  # Creating Start Screen 
  def home():
      start_frame.pack(fill = &quot;both&quot;, expand = 1)
      start_label = Label(start_frame, text = &quot;Performing WAC Calculation&quot;, font = (&quot;Helvetica&quot;, 18)).pack(pady = 40) 
  
  # Creating buttons to codes
  c3231_button = Button(start_frame, text = &quot;Enter Rate for 3231&quot;, command = c3231_code).pack(pady = 5)
  
  # Defining a Main Menu
  my_menu = Menu(root)
  root.config(menu = my_menu)
  
  # Creating Menu Items
  app_menu = Menu(my_menu)
  my_menu.add_cascade(label = &quot;Finance Grid&quot;, menu = app_menu)
  app_menu.add_separator()
  app_menu.add_command(label = &quot;Exit&quot;, command = root.quit)
  
  
  # Showing the Start Screen
  home()
  
  root.mainloop()
  </code></pre>