Friday, 27 February 2026

๐Ÿ“Š Day 39: Pareto Chart in Python

 

๐Ÿ“Š Day 39: Pareto Chart in Python (Interactive Version)


๐Ÿ”น What is a Pareto Chart?

A Pareto Chart combines:

  • ๐Ÿ“Š Bar Chart → shows frequency

  • ๐Ÿ“ˆ Line Chart → shows cumulative percentage

It follows the 80/20 Rule:

80% of problems usually come from 20% of causes.


๐Ÿ”น When Should You Use It?

Use a Pareto chart when:

  • Finding the biggest problem

  • Prioritizing tasks

  • Analyzing complaints

  • Identifying major defect causes


๐Ÿ”น Example Scenario

Customer complaints data:

  • Late Delivery

  • Damaged Product

  • Wrong Item

  • Poor Support

  • Billing Error

We want to know which issue contributes the most.


๐Ÿ”น Python Code (Interactive – Plotly)

import pandas as pd import plotly.graph_objects as go
df = pd.DataFrame({'Issue': ['Late Delivery', 'Damaged Product', 'Wrong Item', 'Poor Support', 'Billing Error'], 'Count': [40, 25, 20, 10, 5]})
df['cum_prct'] = df['Count'].cumsum() / df['Count'].sum() * 100 fig = go.Figure()
fig.add_trace(go.Bar( x=df['Issue'], y=df['Count'], marker_color='#A3B18A', name='Frequency'
)) fig.add_trace(go.Scatter( x=df['Issue'], y=df['cum_prct'],
yaxis='y2', line=dict(color='#BC6C25', width=3),
marker=dict(size=10), name='Cumulative %' ))
fig.update_layout( paper_bgcolor='#FAF9F6', plot_bgcolor='#FAF9F6', font_family="serif",
title="Customer Complaints Analysis", yaxis=dict(title="Frequency", showgrid=False), yaxis2=dict(title="Cumulative %", overlaying='y', side='right', range=[0, 110], showgrid=False),
width=800, height=500, margin=dict(t=80, b=40, l=40, r=40) )

fig.show()
๐Ÿ“Œ Install if needed:

pip install plotly pandas

๐Ÿ”น Output Explanation (Beginner Friendly)

  • The bars show how many complaints each issue has.

  • The tallest bar (Late Delivery) is the biggest problem.

  • The line shows how the percentage increases as issues are added.

๐Ÿ‘‰ The first few issues make up most of the complaints.
๐Ÿ‘‰ After around 80%, the remaining issues have smaller impact.

This helps you focus on solving the most important problems first.


๐Ÿ”น Why This Version Is Better

✅ Interactive (hover to see exact values)
✅ Cleaner design
✅ No matplotlib warnings
✅ More dashboard-friendly


0 Comments:

Post a Comment

Popular Posts

Categories

100 Python Programs for Beginner (119) AI (211) Android (25) AngularJS (1) Api (7) Assembly Language (2) aws (28) Azure (9) BI (10) Books (262) Bootcamp (1) C (78) C# (12) C++ (83) Course (86) Coursera (300) Cybersecurity (29) data (2) Data Analysis (26) Data Analytics (20) data management (15) Data Science (307) Data Strucures (16) Deep Learning (127) Django (16) Downloads (3) edx (21) Engineering (15) Euron (30) Events (7) Excel (18) Finance (10) flask (3) flutter (1) FPL (17) Generative AI (64) Git (10) Google (50) Hadoop (3) HTML Quiz (1) HTML&CSS (48) IBM (41) IoT (3) IS (25) Java (99) Leet Code (4) Machine Learning (252) Meta (24) MICHIGAN (5) microsoft (10) Nvidia (8) Pandas (13) PHP (20) Projects (32) Python (1259) Python Coding Challenge (1050) Python Mistakes (50) Python Quiz (431) Python Tips (5) Questions (3) R (72) React (7) Scripting (3) security (4) Selenium Webdriver (4) Software (19) SQL (46) Udemy (17) UX Research (1) web application (11) Web development (8) web scraping (3)

Followers

Python Coding for Kids ( Free Demo for Everyone)