Pandas is one of the most popular Python packages used in data science. Pandas offer a powerful, and flexible data structure ( Dataframe & Series ) to manipulate, and analyze the data. Visualization is the best way to interpret the data.
Python has many popular plotting libraries that make visualization easy. Some of them are Matplotlib, Seaborn, and Python Plotly. It has great integration with Matplotlib. We can plot a Dataframe using the plot() method. But we need a Dataframe to plot. We can create a Dataframe by just passing a dictionary to the DataFrame() method of the Pandas library.
Plot a Dataframe using Pandas
Let’s create a simple Dataframe:
Python
# importing required library
# In case pandas is not installed on your machine
# use the command 'pip install pandas'.
import pandas as pd
import matplotlib.pyplot as plt
# A dictionary which represents data
data_dict = {'name': ['p1', 'p2', 'p3', 'p4', 'p5', 'p6'],
'age': [20, 20, 21, 20, 21, 20],
'math_marks': [100, 90, 91, 98, 92, 95],
'physics_marks': [90, 100, 91, 92, 98, 95],
'chem_marks': [93, 89, 99, 92, 94, 92]
}
# creating a data frame object
df = pd.DataFrame(data_dict)
# show the dataframe
# bydefault head() show
# first five rows from top
df.head()