How do I get some value in the IntervalIndex ?

Viewed 3801

The variable 'lvl' is IntervalIndex type like following this.

lvl = IntervalIndex([(1.418, 1.69], (1.69, 6.696], (6.696, 7.217], (7.217, 7.845], (7.845, 10.11] ... (17.648, 18.199], (18.199, 19.315], (19.315, 20.16], (20.16, 22.471], (22.471, 25.009]]
          closed='right',
          dtype='interval[float64]') 

Now I've try to append some index value like this:

for each in val_list:  
    for k in range(len(lvl)):
        lower_val = float(lvl[k][1:-1].split(',')[0])
        upper_val = float(lvl[k][1:-1].split(',')[-1])
        if each >=lower_val and each <= upper_val:
            some_var_index.append(k)

But, error raise to me... :

{TypeError}'pandas._libs.interval.Interval' object is not subscriptable 

How do I this? Thank you

1 Answers
Related