- 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.
- ExtGWT Rich Internet Application Cookbook
- 一步一步學(xué)Spring Boot 2:微服務(wù)項(xiàng)目實(shí)戰(zhàn)
- 零基礎(chǔ)搭建量化投資系統(tǒng):以Python為工具
- OpenDaylight Cookbook
- Docker and Kubernetes for Java Developers
- 零基礎(chǔ)學(xué)C++程序設(shè)計(jì)
- PyTorch自動(dòng)駕駛視覺(jué)感知算法實(shí)戰(zhàn)
- Game Programming Using Qt Beginner's Guide
- AWS Serverless架構(gòu):使用AWS從傳統(tǒng)部署方式向Serverless架構(gòu)遷移
- R語(yǔ)言編程指南
- Unity 5 for Android Essentials
- Mastering Linux Network Administration
- Unity 2D Game Development Cookbook
- Learning Probabilistic Graphical Models in R
- Procedural Content Generation for C++ Game Development