Accessing, selecting, and modifying data
In the following section, we will see some basic and advanced methods for indexing, editing, inserting, and deleting data.
Getting ready
A DataFrame
consists of both rows and columns and has constructs to select data from specific rows and columns. These selections use the same operators as a Series
, including []
, .loc[]
, and .iloc[]
.
Because of the multiple dimensions, the process by which these are applied differs slightly. We will examine these by first learning to select columns, then rows, a combination of rows and columns in a single statement, and also by using Boolean selections.
Additionally, pandas provides a construct for selecting a single scalar value at a specific row and column that we will investigate. This technique is important and exists because it is a very high-performance means of accessing these values.
How to do it...
Selecting the data in specific columns of a DataFrame
is performed by using the []
operator. This differs from a...