由于我是Python的新手,由于数组内部的combobox,尝试附加所选元素时遇到了问题。我想附加选定的元素,以便在我的数据框中过滤数据。 我希望它很清楚,很难用文字解释。 谢谢您的帮助。
data = pd.ExcelFile('C:\\Users\\gdeange1\\dev\\Reco_engine\\IMPORT_RECO_SYSTEM.xlsx')
df = data.parse('DATA_PYTHON',index_col=False,na_values=['NA'])
df['SwTelNo'] = df['SwTelNo'].astype(str)
df = df.reset_index()
from tkinter import *
import tkinter as tk
from tkinter import ttk
from sqlalchemy.sql.expression import column
from tkinter import Label, Button, FALSE, Tk, Entry, StringVar
from tkinter.ttk import *
app = tk.Tk()
app.title("Reco Engine Tool")
app.geometry('500x400')
def callbackFunc(event):
global Province
print("Province selected : " + event.widget.get())
def callbackFunc1(event):
global Heading
print("Heading selected : " + event.widget.get())
def callbackFunc2(event):
global Tier
print("Tier selected : " + event.widget.get())
def callbackFunc3(event):
global Channel
print("Channel selected :" + event.widget.get())
def click():
print(Province.get())
print(Heading.get())
print(Tier.get())
print(Channel.get())
listPROVINCE = []
number1= StringVar(app)
keepvalue1 = number1.get()
Province = tk.Label(app,text = "Choose your Province")
Province.grid(column=0, row=0)
Province = ttk.Combobox(app, values=
["QUEBEC","ALBERTA","ONTARIO","ALIANT", "BRITISH COLUMBIA", "SASKATCHEWAN", "MANITOBA"], textvariable=keepvalue1, state='readonly')
Province.grid(column=0, row=1)
Province.bind("<<ComboboxSelected>>", lambda event:callbackFunc(event))
listPROVINCE.append(Province.get())
listHeadingCluster = []
number2= StringVar(app)
keepvalue2 = number1.get()
Heading = tk.Label(app,text = "Choose your Heading Cluster")
Heading.grid(column=0, row=2)
Heading = ttk.Combobox(app, values=["A","B","C","D","E","F"],
textvariable=keepvalue2, state='readonly')
Heading.grid(column=0, row=3)
Heading.bind("<<ComboboxSelected>>", lambda event:callbackFunc1(event))
listHeadingCluster.append(Heading.get())
listTier =[]
number= StringVar(app)
keepvalue = number.get()
Tier = tk.Label(app,text = "Choose your Tier")
Tier.grid(column=0, row=4)
Tier = ttk.Combobox(app, values=["1","2","3","4"],
textvariable=keepvalue, state='readonly')
Tier.grid(column=0, row=5)
Tier.bind("<<ComboboxSelected>>", lambda event:callbackFunc2(event))
listTier.append(Tier.get())
listChannel =[]
number3= StringVar(app)
keepvalue3 = number3.get()
Channel = tk.Label(app,text = "Choose your Province")
Channel.grid(column=0, row=6)
Channel = ttk.Combobox(app, values=["Premise","Advantage","Acquisition", "RPT20", "RPT19", "Client
Relations", "Retention", "Assignment Center", "Cmr", "Canyps Pub",
"Diamond", " Diamond Biz Dev", "Direct Mail"," DoNotAssign", "Dormant Accounts", "House Accounts", "Manitoba Special Accts", "Non Sales", "Retention Premise", "Special Channels", " Third Party Acquisition", "Unassign"], textvariable=keepvalue3, state='readonly')
Channel.grid(column=0, row=7)
Channel.bind("<<ComboboxSelected>>", lambda event:callbackFunc3(event))
listChannel.append(Channel.get())
tk.Button(app, text="Click Here", command=click).grid(column=0, row=9)
app.mainloop()
dataset_2 = df[(df.Tier.isin(listTier) & (df.PROVINCE.isin(listPROVINCE)) & (df.HeadingCluster.isin(listHeadingCluster)) & (df.Channel.isin(listChannel)))]
dataset2 = dataset_2.reset_index()`
我想将使用组合框选择的元素存储在数组中。
例如,对于省份,我将选择“ ALBERTA”并将其附加到listPROVINCE
中。
与其他3个数组(listHeadingcluster
,(listTier
),(listChannel
)相同。
我尝试使用.current()
并成功。例如,在省份中,我将Province.current(1)
设置为“ ALBERTA”,将Heading.current(0)
设置为“ A”,将Tier.current(0)
设置为“ 1”,将Channel.current(0)
设置为“前提”。
这是我尝试Province.get()
,Heading.get()
,Tier.get()
,Channel.get()
时遇到的错误:
ValueError:找到具有0个特征(shape =(1,0))的数组,而check_pairwise_arrays要求至少为1。