笔者最近学习< Machine Learning for Algorithmic Trading >的时候遇到了如下代码,不太了解其中意思,经过学习领悟些许,写此篇以作记录,鉴于本人水平有限,不足之处欢迎批评指正:
idx = pd.IndexSlice
df = df.loc[idx[:, start: end], :]
# start and end don't mean anything special
经了解,IndexSlice适用于多重索引情况下的切片操作,接下来举例说明,例子参考StackOverflow,链接在文末。
index1 = range(0,5)
index2 = list('abc')
index3 = ['I'