Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Series
What DataFrames are
8. Functions head() and tail()
DataFrame columns
DataFrame rows
Filtering rows and columns
Filtering data frames
Sorting rows
Summary

Instruction

Great. After loading the data, the first thing you want to do is take a peek at the data. We can use the head() or tail() functions to quickly see the first/last five rows of our DataFrame.

hospitals.head()

Mind the syntax. We put the variable name hospitals, followed by a dot (.) and the pandas function head(). The dot syntax means that we want to execute the head() function on the variable named hospitals.

The code above will show the following:

Hospital Name City State Phone Number Hospital overall rating
0 Abbeville Area Medical Center Abbeville SC 8643665011 4
1 Abbeville General Hospital Abbeville LA 3378935466 3
2 Avera St Lukes Aberdeen SD 6056225000 5
3 Sanford Aberdeen Medical Center Aberdeen SD 6056264200 4
4 Grays Harbor Community Hospital Aberdeen WA 3605328330 2

The data appear to be correct. Note that the first column contains consecutive numbers, but does not have a name. It's called a sequential index. pandas has created it for us automatically.

Exercise

Now that you have the CSV file loaded into eu_states, show the last five rows from this DataFrame.

Again, you can see the automatic sequential index that pandas created for us. All data seem correct.

Stuck? Here's a hint!

Simply add:

eu_states.tail()