Reputation: 1946
Suppose I have this data structure called test
:
12 2 80.0
4 2.0
6 8.0
7 15.0
8 26.0
...
1095 12 59.0
15 2.0
1098 8 6.0
13 16.0
1128 13 32.0
Length: 62, dtype: float
which is of type: pandas.core.series.Series
Now all I want is the actual coordinates of the values in the right-hand column. I.e.
>>>test[0]
80.0
Then I would like to know how I actually access the hierarchical index for this (and all other values), preferably so that it can be returned as a pair:
>>>test[0].method_which_returns_the_desired_indices()
(12,2)
And of course, the same for the rest of them i.e.
>>>test[2].method_which_returns_the_desired_indices()
(12,6)
How would one go about this? If it helps the test
series was constructed from another pandas data frame using stack()
.
Upvotes: 0
Views: 159
Reputation: 863611
Slice index with integers for positions:
print (test.index[0])
(12, 2)
print (test.index[2])
(12, 6)
Upvotes: 1