🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Pandas Notes
Topic #8

Pandas Analyzing Data


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.

Example

  import pandas as pd

df = pd.read_csv('data.csv')

print(df.head(10))

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

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

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

Example

  import pandas as pd

df = pd.read_csv('data.csv')

print(df.head())

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.

Example

print(df.tail())

Info About the Data

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

Example

print(df.info())

Result Explained

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

RangeIndex: 169 entries, 0 to 168
Data columns (total 4 columns):

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

 #   Column    Non-Null Count  Dtype
---  ------    --------------  -----
 0   Duration  169 non-null    int64
 1   Pulse     169 non-null    int64
 2   Maxpulse  169 non-null    int64
 3   Calories  164 non-null    float64

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.

Want to go beyond the notes?

Join CodingNow 2.0's Pandas course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Pandas Analyzing Data – FAQs

Quick answers about learning Pandas Analyzing Data in Pandas.

This free note from CodingNow 2.0 explains Pandas Analyzing Data in Pandas — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Pandas topic on CodingNow 2.0, including Pandas Analyzing Data, is 100% free with no signup required.
With focused practice, most students grasp Pandas Analyzing Data in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now