What is the point of .ix indexing for pandas Series

后端 未结 1 445
天涯浪人
天涯浪人 2021-01-31 05:26

For the Series object (let\'s call it s), pandas offers three types of addressing.

s.iloc[] -- for integer position addressing;

s.loc[] -- for index label addres

1条回答
  •  鱼传尺愫
    2021-01-31 05:38

    Note: As of Pandas v0.20, .ix indexer is deprecated in favour of .iloc / .loc.

    For a Series, .ix is equivalent of [], the getitem syntax. .ix/.loc support multi-axis indexing, which for a Series does not matter (only has 1 axis), and hence is there for compatibility.

    e.g.

    DataFrame(...).ix[row_indexer,column_indexer]
    Series(...).ix[row_indexer]
    

    .ix itself is an 'older' method that tries to figure out what you want when presented with label or positional (integer) indexing. This is why .loc/.iloc were introduced in 0.11 to provide indexing choice by the user.

    0 讨论(0)
提交回复
热议问题