Explicit lookup by labels with .loc[]

Lookup by label can also be achieved by using the .loc[] property:

There are no problems using integer labels:

Note that .loc[] has a different behavior than .iloc[] when passing an index label that is not in the index. In that case, pandas will return a NaN value instead of throwing an exception:

What is NaN? We will see this in more detail later in the chapter, but pandas uses it for the representation of missing data or numbers that can't be found through index lookups. It also has ramifications in various statistical methods that we will also examine later in this chapter.