لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.


Python Data Science Pandas Analyzing Data Frames

Viewing the Data to Analyze 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.

How to Analyze Data Frames In Pandas?

Example 1: Get a quick overview by printing the first 10 rows of the DataFrame.

Code

import pandas as pd

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

print(df.head(10))

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

Example 2 Use the head method to print the top five rows.

Code

import pandas as pd

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

print(df.head())

the output will be


Example 3: Use the tail method to print the bottom five rows.

Code

import pandas as pd

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

print(df.tail())

the output will be


Info About the Data

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

Example 4: using info() method print information about the data

Code

import pandas as pd

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

print(df.info())

the output will be


Explaination About Data Info

1. The result tells us there are 119 rows and 9 columns.

2. And the name of each column, with the data type.

3. Null Values.

What are Null Values?

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.