- Learning pandas(Second Edition)
- Michael Heydt
- 227字
- 2021-07-02 20:37:10
Lookup by label using the [] operator and the .ix[] property
An implicit label lookup is performed using the [] operator. This operator normally looks up values based upon the given index labels.
Let's start by using the following Series:

A single value can be looked up using just the index label of the desired item:

Multiple items can be retrieved at once using a list of index labels:

We can also look up values using integers that represent positions:

This works purely because the index is not using integer labels. If integers are passed to [], and the index has integer values, then the lookup is performed by matching the values passed in to the values of the integer labels.
This can be demonstrated using the following Series:

The following looks up values at labels 13 and 10, not positions 13 and 10:

Lookup using the [] operator is identical to using the .ix[] property. However, .ix[] has been deprecated since pandas version 0.20.1. The reason for the deprecation is the confusion caused by integers being passed to the operators and the difference in operation depending on the type of the label in the index.
The ramifications of this is that neither [] or .ix[] should be used for lookup. Instead, use the .loc[] and .iloc[] properties, which explicitly look up by label or position only.
- Cocos2D-X權威指南(第2版)
- Debian 7:System Administration Best Practices
- Visual FoxPro程序設計教程
- 基于Java技術的Web應用開發
- Julia機器學習核心編程:人人可用的高性能科學計算
- Learning AWS Lumberyard Game Development
- SQL Server 2016數據庫應用與開發
- Express Web Application Development
- 動手學數據結構與算法
- Mastering Web Application Development with AngularJS
- Android應用開發深入學習實錄
- C++程序設計教程
- Python Web自動化測試設計與實現
- Yii2 By Example
- JavaWeb從入門到精通(視頻實戰版)