[英]How can I clear all the data from my dataframes so they're empty for the next iteration through my for loop?
[英]How can I modify my for loop so that it extracts the correct data
thread_list = ['DWr','Idle','MulWr','Lock']
Target_list = ['0','0','0','1']
trd_coor = [26,10,51,10,226,10,251,10]
mem_coor = [10,215,35,215,60,215,85,215]
targ_1 = ['write','unchachable']
count_T = 0
count_X1 = 0
count_Y1 = 0
count_target = 0
count_target_1 = 0
count_dash_T = 0
T = []
trd_Y1 = []
count_dash_T_list = [0,1,2,3]
for i in trd_coor[1::2]:
Y1 = i
trd_Y1.append(Y1)
for i in range(0,len(count_dash_T_list)):
target = Target_list[count_target]
count_target += 1
print(target)
for i in targ_1:
if (target == '0'):
if (i == 'write'):
X2 = mem_coor[0]
Y2 = mem_coor[1]
elif (target == '1'):
if (i == 'uncachable'):
X2 = mem_coor[2]
Y2 = mem_coor[3]
else:
break
print(X2)
print(Y2)
當 target_list 中的元素為 1 時,我希望 output 為 35,215,這是我當前的 output:0 10 215 0 10 215 0 10 215 1 10 215
這是我想要的 output:0 10 215 0 10 215 0 10 215 1 35 215
所以有兩個問題
unchachable
的錯字break
的else
語句如果你仔細看for
話當我們 go 進入最后
for i in targ_1:
if (target == '0'):
if (i == 'write'):
X2 = mem_coor[0]
Y2 = mem_coor[1]
elif (target == '1'):
if (i == 'uncachable'):
X2 = mem_coor[2]
Y2 = mem_coor[3]
else:
break
target
值為1
所以我們 go 到elif
並檢查if
聲明。 但是i
是write
的,所以我們 go 到else
然后break
。
如果您更改類型並刪除中斷,那么它應該可以工作
thread_list = ['DWr','Idle','MulWr','Lock']
Target_list = ['0','0','0','1']
trd_coor = [26,10,51,10,226,10,251,10]
mem_coor = [10,215,35,215,60,215,85,215]
targ_1 = ['write','unchachable']
count_T = 0
count_X1 = 0
count_Y1 = 0
count_target = 0
count_target_1 = 0
count_dash_T = 0
T = []
trd_Y1 = []
count_dash_T_list = [0,1,2,3]
for i in trd_coor[1::2]:
Y1 = i
trd_Y1.append(Y1)
for i in range(0,len(count_dash_T_list)):
target = Target_list[count_target]
count_target += 1
print(target)
for i in targ_1:
if (target == '0'):
if (i == 'write'):
X2 = mem_coor[0]
Y2 = mem_coor[1]
elif (target == '1'):
if (i == 'unchachable'):
X2 = mem_coor[2]
Y2 = mem_coor[3]
print(X2)
print(Y2)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.