Issue
I have this CSV data file, I'm trying to make a pie chart using this data
I'm a beginner in python and don't understand how to create a pie chart using the three columns, please help!
working solution code would be more helpful!
My code:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv ('chart_work.csv')
product_data = df["Product Name;"]
bug_data = df["Number Of Bugs"]
colors = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#8c564b"]
plt.pie(bug_data , labels=product_data , colors=colors,
autopct='%1.1f%%', shadow=True, startangle=140)
plt.show()
the pie chart which is outputed by this code is distorted, any help?
Chart I'm getting:
Solution
This is very simple.
import pandas as pd
from matplotlib.pyplot import pie, axis, show
%matplotlib inline
df = pd.read_csv ('chart_work.csv')
sums = df.groupby(df["Product Name;"])["Number Of Bugs"].sum()
axis('equal');
pie(sums, labels=sums.index);
show()
Answered By - Ashok Rayal Answer Checked By - Terry (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.