Pandas Tutorial · Pandas Tutorial

Pandas Analyzing Data

Learn all about Pandas Analyzing Data in this comprehensive tutorial.

5 min read intermediate
  • One of the most used method for getting a quick overview of the DataFrame, is the head() method.
  • The DataFrames object has a method called info(), that gives you more information about the data set.
  • The result tells us there are 169 rows and 4 columns:
  • The info() method also tells us how many Non-Null values there are present in each column, and in our data set it seems like there are 164 of 169 Non-Null values in the "Calories" column.

Viewing the Data

One of the most used method for getting a quick overview of the DataFrame, is the head() method.

The head() method returns the headers and a specified number of rows, starting from the top.

python

In our examples we will be using a CSV file called 'data.csv'.

Download data.csv, or open data.csv in your browser.

Note: Note: if the number of rows is not specified, the head() method will return the top 5 rows.
python

There is also a tail() method for viewing the last rows of the DataFrame.

The tail() method returns the headers and a specified number of rows, starting from the bottom.

python

Info About the Data

The DataFrames object has a method called info(), that gives you more information about the data set.

python

Result Explained

The result tells us there are 169 rows and 4 columns:

And the name of each column, with the data type:

Null Values

The info() method also tells us how many Non-Null values there are present in each column, and in our data set it seems like there are 164 of 169 Non-Null values in the "Calories" column.

Which means that there are 5 rows with no value at all, in the "Calories" column, for whatever reason.

Empty values, or Null values, can be bad when analyzing data, and you should consider removing rows with empty values. This is a step towards what is called cleaning data, and you will learn more about that in the next chapters.

Module quiz

2 questions
1

Which of the following is true about Pandas Analyzing Data?

2

What is the most common pitfall when working with Pandas Analyzing Data?

Answer all questions to submit.