How to Generate Graphs from Excel Data using Python

In today’s world, data plays a critical role in the decision-making of any size of the organization. Analyzing data usually begins with its visualization and one of the most common ways of visualizing data is through graphs.

In this tutorial, we will learn how to generate graphs from Excel data using Python. We will use Python’s two powerful libraries: Pandas for Data Analysis and Matplotlib for data visualization.

Step 1: Install Necessary Libraries

Install Pandas, Numpy, Matplotlib, and xlrd using pip:

Step 2: Import Required Libraries

You need to import the necessary libraries into your Python script. Below is the Python code to import them:

Step 3: Load Excel Data with pandas

Below is an example of Excel data with two columns “Months” and “Sales”. The file is named “sales_data.xlsx”.

Month,Sales
Jan,100
Feb,120
Mar,190
Apr,110
May,105
Jun,120
Jul,135
Aug,145
Sep,130
Oct,120
Nov,115
Dec,130

Now, Let’s load this Excel data using the pandas read_excel function:

Output:

   Month  Sales
0    Jan    100
1    Feb    120
2    Mar    190
3    Apr    110
4    May    105
5    Jun    120
6    Jul    135
7    Aug    145
8    Sep    130
9    Oct    120
10   Nov    115
11   Dec    130

Step 4: Plot the Data

Now, use Matplotlib to visualize this data:

Step 5: Full Code

Conclusion

That’s it! You have plotted Excel data using Python. Python provides powerful libraries such as Pandas for data manipulation and Matplotlib for data visualization which makes your job easier and more efficient.

So, start incorporating them into your workflow and save precious time and effort for important decision-making.