for a math paper I need to make N slices and output them to as many different txt files as there are slices made. Everything should be saved in TXT. I mean, I need to write each new step of the cycle to a new file.
N=10
j=1
for i in range (1,N):
df_step=df2 [j::N]
j+=1
np.savetxt(r'c:\Data\step.txt', df_step, fmt='%s')
need each step of the loop to be saved to a file named step_1, step_2, step_3, ...., step_i.
np.savetxt(r'c:\Data\step.txt', df_step, fmt='%s')
What should i change here?
np.savetxt(fr'c:\Data\step_{i}.txt', df_step, fmt='%s'). And you can replacejbyi, it's useless to have two counters.