Selecting values using an index

Values can be looked up using an index using the [] operator or by using the following property indexers of a Series or DataFrame:

.loc[]

Looks up by the label, not the location. But be careful; if the labels are integers, then integers will be treated as labels!

.at[]

Like .loc[], but this can only retrieve a single value.

.iloc[]

Lookup is based on the 0-based position and not the index label.

.ix[]

Hybrid, which when given an integer will attempt 0-based lookup; other types are label-based. This is going to be deprecated, so stick with the other three properties.

Values can be looked up in a Series by using the [] operator as in the following DataFrame, which has its b value retrieved.

Lookup using [] on a Series is equivalent to using the .loc[] property.

The [] operator retrieves columns instead of the rows when applied to DataFrame.

To look up via the row index with a DataFrame, one of the property indexers must be utilized.

The property indexer forms are also able to use slicing.

And it is also possible to pass a list of values.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset