From the course: pandas Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using head() and tail()

Using head() and tail() - pandas Tutorial

From the course: pandas Essential Training

Start my 1-month free trial

Using head() and tail()

- [Instructor] The head and the tail return the first and last N rows of a DataFrame. This is one of the first steps after reading a file into a Pandas DataFrame just to get a feel of the rows and columns involved. By default you will get the first five rows and the last five rows if you don't specify any value of N. Let's head over to our Jupyter Notebook. So, we enter our DataFrame which is 00 and head. And that gives us the first five rows of our DataFrame. Alternatively, if we want the last five rows, we enter 0.tail and that gives us the last five rows and so, we can see that the first five, the data seems to be sorted by the edition, the first five are the ones for the first Olympics and the last five are from the information that we have on the last Olympics from the 2008. A helpful tip is that sometimes if you sorted your DataFrame or series, you might only want to display the top three results. You can do that by typing 00.head and three and that will give you the top three…

Contents