1

Python Tkinter モジュールを使用して、ユーザー データを受け入れるアプリを構築しようとしています。csv ファイルで作成された pandas データフレームで関数を呼び出します。次に、結果を ap の画面ボックスに出力します。

ここに私の試みがありますが、出力が得られません:

import pandas as pd
import ttk

def parsefile(*args):
    try:
      df=pd.read_csv("dataforcluster.csv")

      # do something to the data...

      df.ix[(df.sp-x).abs().argsort()[:5]]

    except ValueError:
      pass

root = Tk()
root.title("Closest_5")

 mainframe = ttk.Frame(root, padding="3 3 12 12")
 mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
 mainframe.columnconfigure(0, weight=1)
 mainframe.rowconfigure(0, weight=1)

 sp_price_change = StringVar()
 output = StringVar()

 sp_price_change_entry = ttk.Entry(mainframe, width=7, textvariable=sp_price_change)
 sp_price_change_entry.grid(column=2, row=1, sticky=(W, E))

 ttk.Label(mainframe, textvariable=output).grid(column=2, row=2, sticky=(W, E))
 ttk.Button(mainframe, text="Calculate", command=parsefile).grid(column=3, row=3, sticky=W)

 ttk.Label(mainframe, text="sp_price_change").grid(column=3, row=1, sticky=W)
 ttk.Label(mainframe, text="is equivalent to").grid(column=1, row=2, sticky=E)
 ttk.Label(mainframe, text="output").grid(column=3, row=2, sticky=W)

 for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)

   sp_price_change_entry.focus()
   root.bind('<Return>', calculate)

  root.mainloop()

サンプル データはこちらから取得できます: https://www.dropbox.com/s/yxx0rtio15dzmfq/dataforcluster.csv

ご提案いただきありがとうございます。

4

1 に答える 1