Q:

Change index name in Pandas using info from columns (key)

Good afternoon all,
I am new to both Python and Pandas and wanted to know how to rename the index name with that of concatenated columns info.
For example rename the below:
      Bus1 Bus2 Bus3 ...

0     12   45   50   ...
0     12   45   51   ...
0     13   22   44   ...

To:
          Bus1 Bus2 Bus3 ...
12_45_50  12   45   50   ...
12_45_51  12   45   51   ...
13_22_44  13   22   44   ...

I basically would like the Index to be a key using column info.  Thank you very much in advance for the help

A:

Use:
df.set_index(df.astype(str).apply('_'.join, axis=1), inplace=True)

[out]
          Bus1  Bus2  Bus3
12_45_50    12    45    50
12_45_51    12    45    51
13_22_44    13    22    44

