- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Pandas - Plot multiple data columns in a DataFrame?
To plot multiple columns, we will be plotting a Bar Graph. Use the plot() method and set the kind parameter to bar for Bar Graph. Let us first import the required libraries −
import pandas as pd import matplotlib.pyplot as mp
Following is our data with Team Records −
data = [["Australia", 2500, 2021],["Bangladesh", 1000, 2021],["England", 2000, 2021],["India", 3000, 2021],["Srilanka", 1500, 2021]]
Set the data as Pandas DataFrame and add columns −
dataFrame = pd.DataFrame(data, columns=["Team","Rank_Points", "Year"])
Plot multiple columns in a bar graph. We have set the “kind” parameter as “bar” for this −
dataFrame.plot(x="Team", y=["Rank_Points","Year" ], kind="bar", figsize=(10, 9))
Example
Following is the code −
import pandas as pd import matplotlib.pyplot as mp # our data data = [["Australia", 2500, 2021],["Bangladesh", 1000, 2021],["England", 2000, 2021],["India", 3000, 2021],["Srilanka", 1500, 2021]] # dataframe dataFrame = pd.DataFrame(data, columns=["Team","Rank_Points", "Year"]) # plotting multiple columns in a bar Graph dataFrame.plot(x="Team", y=["Rank_Points","Year" ], kind="bar", figsize=(10, 9)) # displaying bar graph mp.show()
Output
This will produce the following output −
- Related Articles
- Plot multiple columns of Pandas DataFrame using Seaborn
- Python - Select multiple columns from a Pandas dataframe
- Select multiple columns in a Pandas DataFrame
- Plot multiple columns of Pandas dataframe on the bar chart in Matplotlib
- How to sort multiple columns of a Pandas DataFrame?
- Python - Grouping columns in Pandas Dataframe
- Python - Name columns explicitly in a Pandas DataFrame
- Python - Plot a Pandas DataFrame in a Line Graph
- Python Pandas - Query the columns of a DataFrame
- Python - Draw a Scatter Plot for a Pandas DataFrame
- Frequency plot in Python/Pandas DataFrame using Matplotlib
- Python - Renaming the columns of Pandas DataFrame
- Python – Reshape the data in a Pandas DataFrame
- Python Pandas – Count the rows and columns in a DataFrame
- Python - Plot a Histogram for Pandas Dataframe with Matplotlib?

Advertisements