pandas mix position and label indexing without chaining
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Since .ix has been deprecated as of Pandas 0.20 , I wonder what is the proper way to mix lable-based, boolean-based and position-based indexing in Pandas? I need to assign values to a slice of dataframe that can be best referenced with label or boolean on the index and position on the columns. For example (using .loc as placeholder for the desired slicing method): df.loc[df['a'] == 'x', -12:-1] = 3 obviously this doesn't work, with which I get: TypeError: cannot do slice indexing on <class 'pandas.core.indexes.base.Index'> with these