unexpected IndexError

I am getting a really strange error when executing following lines

IndexError: index 2 is out of bounds for axis 0 with size 2

This is unexpected to me because it only happens to this 2 RICs. Anyone has any clue on why these 2 RICs are so special?


rics = ['005110.KS', '005160.KQ']
df2 = ek.get_timeseries(rics=rics, start_date='2021-04-06', end_date='2021-04-06', corax='unadjusted')
df2.stack(level=-2)

Best Answer

  • jason.ramchandani01
    Answer ✓

    @Max.Zhu Yes it took me a while! So the issue here seems to be something with the stack routine that doesn't like integer values. So if you look at df2.info() for the Korean stocks that are causing issues - they are of int64 type:

    image

    Now if I change the dataframe Dtype from int64 to float then try the stack:

    df3 = df2.astype(float).copy()
    df3.stack(level=-2)

    image

    It all works fine, So I believe this is some DType issue with Pandas' stack routine. I will also speak to the dev team to check if the type conversions at our end are all correct.

    I also checked with some other RICs ['VOD.L','BARC.L'] and they returned a mixture of floats and ints and it all worked correctly. I hope this can help.


Answers