0

I am creating a pandas df2 for every iteration from a for loop in python. I am trying to append this df2 to new df3 for every iteration. But the resulting is not coming in the order of the iteration, instead it gets arranged based on the index number. how to rectify this? Below is just a pseudocode.

df3 = pd.DataFrame(columns = column_names)

for i in range(len(hansen_sort)):
    idx=hansen_index[i]
    start=api[i]
    end=id[i]+1
    df2=df1.iloc[start : end]
    df3.append(df2)
mozway
  • 81,317
  • 8
  • 19
  • 49
pred
  • 149
  • 4

0 Answers0