pandas.cut can return a missing category even when the source value is present. Check whether the value sits on an excluded boundary or outside your specified bin range. Keep these unclassified known values separate from genuinely missing source amounts before reporting category totals.
A USD report with three different reasons for missing bands
A fictional analyst combines USD-normalized order values for US, UK, and European operations. The six input amounts are $0, $50, $100, $200, $250, and one unknown amount. The business rule for this exercise is low from $0 through $100, and high above $100 through $200. Values beyond $200 require review.
The zero is a valid recorded amount in this fixture. The $250 record is also present, but exceeds the configured reporting range. The unknown amount has no numeric value. These cases should not all receive the same explanation just because their first classification results look alike.
Run the boundary and coverage checks
This reproducible example was tested with pandas 2.3.3. The UNASSIGNED text is used only to make the printed output readable; it does not overwrite the numeric source or the original category values.
import pandas as pd
amount = pd.Series([0, 50, 100, 200, 250, None], name='usd')
bad = pd.cut(amount, [0, 100, 200], labels=['low', 'high'])
band = pd.cut(amount, [0, 100, 200], labels=['low', 'high'], include_lowest=True)
source_missing = amount.isna()
unassigned_known = amount.notna() & band.isna()
assert bad.isna().tolist() == [True,False,False,False,True,True]
assert band.astype('object').fillna('UNASSIGNED').tolist() == ['low','low','low','high','UNASSIGNED','UNASSIGNED']
assert source_missing.sum() == 1
assert unassigned_known.sum() == 1
print(band.astype('object').fillna('UNASSIGNED').tolist())
print('source missing:', source_missing.sum())
print('known but unassigned:', unassigned_known.sum())
What do the results mean?
The first classification leaves three inputs without a category: zero, $250, and the unknown amount. After including the lowest boundary, the corrected bands are low, low, low, high, unassigned, unassigned. Only one of those final unassigned records is a missing source amount. The other is the known $250 value outside the configured range.
The classified known amounts total $350: $0 + $50 + $100 + $200. All known input amounts total $600. The $250 difference is an unclassified known amount, not evidence of lost source rows. The unknown record means neither total represents a complete sum of all six order amounts.
Which endpoints does cut include?
With these explicit bin edges and the default right=True, the intervals are (0, 100] and (100, 200]. Zero is excluded unless include_lowest=True is supplied; $100 belongs to the first interval, and $200 to the second. The official pandas.cut reference documents these boundary options and the missing results produced by out-of-range inputs.
Changing right=False changes the business rule to left-inclusive intervals. It is not a general repair for missing values: with the same finite edges, $200 would then be excluded. Choose the endpoint convention from the reporting definition and test exact boundary amounts.
Should the highest band be open-ended?
Only if the intended definition includes every amount above $100. In that case, an upper edge of positive infinity would include $250 in the high band. In this exercise, $200 is an explicit review threshold, so silently widening it would conceal an exception that the report is supposed to show.
Likewise, do not force unassigned records into low or high with a blanket fill operation. Investigate whether the rule needs a new band, the source needs correction, or the record should remain a labeled exception. Preserve the original amount so a reviewer can reproduce the decision.
How do you make the report auditable?
Reconcile the input row count with classified rows, known unclassified rows, and missing-source rows. Here those counts are 4 + 1 + 1 = 6. Keep a separate table of the known exceptions with their order IDs in a real dataset. This small fixture uses row positions only for a reproducible demonstration.
Validate currency normalization before applying shared monetary thresholds across markets. A raw GBP or EUR amount should not enter a USD band without the intended conversion rule. Check negative amounts separately if refunds are possible; this exercise has no negative records and does not specify how a refund should be classified.
For fixed business thresholds, keep the same documented edges across periods. If the task instead asks for quantile-based groups, see the separate qcut duplicate-edge example. For strings that fail numeric conversion, use the numeric parsing audit before binning.
How would you explain the finding?
“The classification initially excluded zero at the lower boundary. After correcting that convention, four rows are classified, one known amount remains outside the approved range, and one amount is missing. I would report those exception types separately and reconcile both row counts and known dollar totals.”