0

Data

ID  Q1  Q2  Q3
AA  1   2   4
BB  5   5   5
CC  6   7   7

Desired

ID  Q1  Q2  Q3
BB  5   5   5
CC  6   7   7
AA  1   2   4

Doing

df = pd.DataFrame(df, index = ["BB","CC","AA"])

This is simply adding the row name, I wish to rea arrange row order based on name. Any suggestion is appreciated.

4
  • What's the arrange logic? Commented May 31, 2023 at 1:16
  • No Particular arrange logic, just looking to see if it is possible to reindex based on column values and not the row number @Ynjxsjmh Commented May 31, 2023 at 1:55
  • Suppose df is DataFrame. reindex by df.reindex(["BB","CC","AA"]) is that right? Commented May 31, 2023 at 2:59
  • I’ll try this , not sure if I can actually rearrange using values unless using loc. l try thanks @Nguyen Commented May 31, 2023 at 3:53

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.