pandas pivot_table, get index of certain row

1.6k views Asked by At

I created pivot table:

matrix_df = data.pivot_table(index = 'title', columns = 'userId', values = 'rating')

So, for each 'title' I have row of some numerical data. I create 2d array out of this numerical data:

matrix = matrix_df.to_numpy()

Then I did something with this data and find that row I need has index 32. Now I want to check what is the title of row 32. I can access this row from matrix_df:

matrix_df.iloc[32]

But how I can get the actual title? enter image description here

1

There are 1 answers

0
fmarm On

Since title seems to be your index, you can just extract the value for index at the row 32

matrix_df.index[32]