I have a text file with 8 columns
# 0.y[m] 1.uy[m_e*c] 2.x[m] 3.ux[m_ec] 4.z[m] 5.uz[m_ec] 6.w 7.ID
.
In this file, the first line is commented with #
and there is no label for the data columns. I import this file in a data frame using
data = pd.DataFrame(pd.read_csv("41.dat", sep='t', comment='#', header=None));
and diplaying it I see:
Now, I need to sort ascending for the last column so I use index 7 and this code line
dataS = currentData.sort_values(7);
and sorting works because now I see
but sorting is not persistent because
data[7][0] = 24641553
and
dataS[7][0] = 24641553
I need to use the sorted data frame one row after the other, exactly in the sorted order, so my code will rely on a for loop which uses dataS[7][i]
where i = 0, 1, 2, …
Can anyone help please? Thanks!