Pandas plotting

A picture is worth a thousand words. This is why graphs are commonly used to visually illustrate relationships in data. The purpose of a graph is to present data that is too numerous or complicated to be described adequately in terms of text and in less space. With Python's plotting function, it takes far less than a few words of code to create a production-quality graphic.

We will begin by installing the necessary packages:

import pandas as pd 
import numpy as np 

We are using the mtcars data here to explain the plots:

mtcars = pd.DataFrame({ 
        'mpg':[21,21,22.8,21.4,18.7,18.1,18.3,24.4,22.8,19.2], 
        'cyl':[6,6,4,6,8,6,8,4,4,4], 
        'disp':[160,160,108,258,360,225,360,146.7,140.8,167.7], 
  'hp':[110,110,93,110,175,105,245,62,95,123],    
'category':['SUV','Sedan','Sedan','Hatchback','SUV','Sedan','SUV','Hatchback','SUV','Sedan'] 
        }) 
mtcars 

This results in the following output:

mtcars DataFrame

Let's discuss the various plots in pandas.plotting in detail.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset