-1
我想從一個函數返回一個值到另一個函數並使用它來過濾我的excel。下面是什麼我試圖做的事:從一個函數傳遞返回參數另一個函數
@app.route("/bzrules")
def show_tables():
rules = pd.read_excel('static/dummy_data.xlsx')
df = pd.read_excel('static/Book1.xlsx')
valid=pd.read_excel('static/rules.xls')
rules.set_index(['DR_ID'], inplace=True)
rules.index.name=None
allfields3=rules.loc[rules['DQ_Dimension']=='Accuracy']
allfields2 = allfields3[['Subject_Area','Field_Name']]
if request.method == 'GET':
subarealist = rules['Subject_Area'].unique().tolist()
validvalues=valid['Field_Name'].loc[valid['Rule_Type']=='Valid Value Check']
# this is were user selection from first function assigned to seach_key variable. i want to pass this variable to another function below.
在我先前的職位subarealist
是用戶的選擇。
在這一請求,我現在的儲蓄在一個變量我的用戶選擇,並試圖變量傳遞給另一個函數
search_key = request.args.get('fieldnames')
@app.route('/postfields')
def postfields():
# i tried doing like below, but getting errors
search_key=show_tables()
dt=pd.read_excel('static/AllDataSheets.xlsx',sheetname=search_key)
請不要轉發問題。如果您已更新有關問題的信息,請編輯現有問題以顯示該問題。 – davidism
哪個變量有你需要傳遞的用戶選擇?字段名是變量還是字符串? – brennan