How to keep the number of each row?

I may be wrong, but the numbers 7, 8, etc. are probably behaving more like a row name than a row number. What I mean by that is I expect the following to happen, if if I'm not terribly wrong.

  1. df[7,] is going to extract the row with number 20
  2. df["7",] will extract the first row

If that is indeed the case for you, I'll suggest to convert these to a column of row names, and let the row numbers being usual, i.e. start from 1. In that way, you'll continue to have the information you need.

If this is not an acceptable solution for you, you need to provide a reprex and share some more context as required. At the least, the reprex will need a copy-paste friendly data, and the code for "normalized transformation".

1 Like