0

How to get a column name if we have row name and the value which is there in that row.

For example:

Attached Image

In attached image, if we know the row name is GameCube and the value in that row is 7.608333, then how to get column name as Action,Adventure?

for col in ign_data:
    if ign_data[col]['GameCube'] == 7.608333:
        print(ign_data.columns[col])

I tried it using for loop but getting value error:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • You have many options, on of them: `ign_data.columns[ign_data.loc['GameCube'] == 7.608333]` or `ign_data.columns[np.isclose(ign_data.loc['GameCube'], 7.608333)]` – mozway Mar 27 '23 at 08:59

0 Answers0