Operations and manipulations of pandas
There are a number of operation methods used to work in pandas
. In this section of the chapter, we will look into some of the common operations that we will be doing in this book.
Inspection of data
The first thing that you will want to do when loading a DataFrame or creating a DataFrame from a file is to inspect the data that you just loaded. We have two methods for inspecting the data:
- Head
- Tail
The head
method will show us the data of the first five rows:

As you can see in the precedingscreenshot, we have the first five rows and 34 columns displayed on running the data.head()
method:

To take a look at the last five rows of data, you use the tail
method. The preceding screenshot shows us the last five rows of data from our DataFrame on running the data.tail()
method. It is always a good practice to use these two methods to make sure that the data is correctly loaded.
Selection, addition, and deletion of data
You can view DataFrames as a dictionary of a series...