← Back to Pandas Course | Chapter 12: Visualization Basics | Lesson 4 of 6

Box Plot बनाना

Box plot किसी distribution के median, quartiles और outliers को एक compact picture में summarize करता है।

In this page:

  1. Box plot
Syntax
python
df.plot.box()
df.boxplot(column="value_column", by="group_column")

Box plot

df.plot.box() या df.boxplot(by=...) median line, Q1 से Q3 तक का box, whiskers, और outliers के लिए dots बनाता है। यह columns या groups में distributions को एक नज़र में compare करता है।

Note: Whiskers से बाहर के points संभावित outliers हैं।

उदाहरण: Box plot

python
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import pandas as pd

df = pd.DataFrame({"a": [10, 12, 11, 13, 12, 40], "b": [20, 22, 21, 23, 22, 24]})
ax = df.plot.box()
print("boxes:", len(ax.lines) // 6 if len(ax.lines) >= 12 else len(ax.lines))
print(df.describe().loc[["min", "50%", "max"]])

# Output:
# boxes: 2
#         a     b
# min  10.0  20.0
# 50%  12.0  22.0
# max  40.0  24.0
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. box line को mean समझना
  2. whiskers की definition को नज़रअंदाज़ करना
  3. बहुत छोटे samples पर इसका उपयोग करना
चैप्टर सारांश
  • Box median और quartiles दिखाता है
  • Whiskers spread दिखाते हैं
  • Dots outliers को चिह्नित करते हैं
  • groups को साथ-साथ compare करें
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.