ERed ERed - 1 year ago 137
Python Question

get multiindex value based on row number in Pandas

Is there any way to retieve the multiindex value based on the number of row?
Like can I use

to retrieve somehow the value of the multiindex in an array form?

For example I have a multiindex [month, day, hour]. Can i use iloc[numRow] and get for exmple (1,1,1) being the multiindex values month 1, day 1 and hour 1?

does not work since it becomes a series and then it returns the column names as the index, but I really want the value of the multiindex of the row.

Answer Source

How about:


(You can always use integer-based slicing on Index objects...)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download