我目前正在尝试运行此循环-
for i in [R1, R2, R3, R4, R5, R6]:
i = i[i.route == int(m)]
i['stop'] = i['stop'].astype(str)
i['route_sequence'] = i.stop.str[0:3]
i = i[i["time2"] != 0]
i['sequence'] = np.roll(i['route_sequence'], 1)
i['Seconds'] = pd.to_numeric(i['Seconds'], errors='coerce')
i_Unique = i['route_sequence'].unique()
但是,一旦它超过了代码的第一行(i = i [i.route == int(m)]),它就不会执行任何剩余的任务。它也没有给我任何错误,所以我想知道自己在做错什么。
编辑-
在for循环中的m在这里定义
for m in ["1", "2", "3", "4", "5", "6"]:
exec('{} = pd.DataFrame(pd.read_csv("R_" + m + ".csv"))'.format("R" + m))