我知道大熊猫提供:
.ix - 混合标签和位置索引(主要是标签),如果索引是整数 - 它将被解释为标签.loc - 按标签显式索引.iloc - 按位置显式索引 这很酷.
什么是通过标签(ala .loc)和按位置(ala .iloc)一次索引列的正确方法,以避免链式分配?优选地,它会避免reset_index().
为了提供示例,假设以下DataFrame df:
col1 col2 col3
3 1 4 2
2 2 3 3
4 3 2 1
1 4 1 4
Run Code Online (Sandbox Code Playgroud)
大熊猫有类似的东西some_indexer,其行为如下?
In[2]: df.some_indexer[2,'col2':'col3']
Out[2]:
col2 2
col3 1
Name: 4, dtype: object
Run Code Online (Sandbox Code Playgroud)
谢谢!