Binning Data
Convert continuous values into discrete categories using cut() and qcut().
Basic Binning with cut()
Divide values into fixed-width bins:
Loading Pandas Playground...
Custom Bin Edges
Specify exact boundaries:
Loading Pandas Playground...
Quantile-Based Binning with qcut()
Create bins with equal number of observations:
Loading Pandas Playground...
Without Labels
Get the actual bin ranges:
Loading Pandas Playground...
Include Edge Values
Control which edge is included:
Loading Pandas Playground...
Binning for Visualization
Prepare data for histograms:
Loading Pandas Playground...
Exercise: Grade Bins
Loading Exercise...
Exercise: Quartile Split
Loading Exercise...
Key Points
pd.cut()creates equal-width binspd.qcut()creates equal-frequency binsbins=defines boundaries or number of binslabels=assigns names to binsright=Falseincludes left edge instead- Useful for grading, grouping, visualization
Up next · Lesson 33 of 42
Reshaping Data
1 min read
32 of 42 lessons done

Ask Byte about this lesson
A private chat about this lesson. Byte has read the whole lesson, answers in seconds, and shows the section each answer comes from. Ask follow-ups in any language.
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

