到目前为止,这是我的代码
def sbc(): #splits up dataframe by account
accounts = []
acc = raw_input("Enter account abbreviations one at a time. Enter 'end' to load media lists.")
frame = rlf()
while True:
if acc == 'end':
break
else:
accounts.append(acc)
for ac in accounts:
frame = frame[frame['Campaign'].str.startswith(ac)]
path = r'C:\\Users\\CP\\Documents\\Python_WL\\'+str(ac)+str(time.strftime("%d.%m.%Y"))+'.xls'
if len(frame) > 50:
frame.to_excel(path)
我希望能够在'account'中有多个条目,但是,当我运行程序时,它只允许我输入一个值。我倍加困惑,因为另一部分代码确实以我想要的方式重复代码为“帐户”:
def rlf(): #removes low fill rate
frame = rbs()
inputted_fill_rate = raw_input("Fill Rate cutoff? (Format: 0.nn): ")
return frame[frame['Fill Rate'] >= float(inputted_fill_rate)]
答案 0 :(得分:1)
将raw_input
调用移至循环内部。您可能还希望取消缩进for
循环。
def sbc(): #splits up dataframe by spotx account
accounts = []
frame = rlf()
while True:
acc = raw_input("Enter account abbreviations one at a time. Enter 'end' to load media lists.")
if acc == 'end':
break
else:
accounts.append(acc)
for ac in accounts:
frame = frame[frame['Campaign'].str.startswith(ac)]
path = r'C:\\Users\\CP\\Documents\\Python_WL\\'+str(ac)+str(time.strftime("%d.%m.%Y"))+'.xls'
if len(frame) > 50:
frame.to_excel(path)