Error and warning codes

Every code an svy error or warning carries, with the class it is raised as.

Every svy error and warning carries a code, listed in svy.errors.Code. The class names the part of svy that raised it, and each error is also a Python builtin: except svy.errors.ModelError, except ValueError and except svy.SvyError all catch ModelError.ValueError. Warnings are filtered by their class, warnings.filterwarnings("ignore", category=svy.errors.WeightingWarning), or by code, warnings.filterwarnings("ignore", message=r"\[GLM_SEPARATION\]").

Shared

Code Raised as Message Hint
DATA_ROWS_CHANGED <Area>Error.ValueError Rows changed outside svy Change rows through svy: sample.wrangling.filter_records to drop records, sample.wrangling.join to bring variables in, svy.combine_samples to stack samples. For an unrelated frame, build a new Sample(data, design).
EMPTY_ESTIMATES <Area>Error.ValueError No estimates to display
GROUP_LEVELS_MISMATCH <Area>Error.ValueError Group levels mismatch
INVALID_CHOICE <Area>Error.ValueError, DataError.ValueError, DesignError.ValueError, EstimationError.ValueError, ModelError.ValueError, UsageError.ValueError Unknown replication method Use ‘brr’, ‘bootstrap’, ‘jackknife’, or ‘sdr’.
INVALID_RANGE <Area>Error.ValueError, WeightingError, WeightingError.ValueError Invalid numeric range bounds=(lo, hi) bounds the factor g = new/old weight; None on a side leaves it open, e.g. bounds=(0.5, None) or bounds=(0.5, 2.0).
INVALID_TYPE <Area>Error.TypeError, WeightingError Invalid type bounds=(lo, hi) bounds the factor g = new/old weight; None on a side leaves it open, e.g. bounds=(0.5, None) or bounds=(0.5, 2.0).
INVALID_VALUE <Area>Error.ValueError Invalid value
METHOD_NOT_APPLICABLE <Area>Error.ValueError Method not applicable
MISSING_COLUMNS <Area>Error.KeyError, DataError.KeyError, DataError.ValueError, DesignError.KeyError, IoError.KeyError, ModelError.ValueError, WeightingError.KeyError Column(s) not found Check spelling or inspect sample.data.columns.
PARAM_RENAMED <Area>Error.TypeError, DesignError.TypeError Parameter removed Replace …= with …=.
REP_WGTS_MISSING <Area>Error.ValueError, DesignError.ValueError No replicate weights Create replicate weights with sample.weighting.create_*_wgts, or use method=‘taylor’.
REP_WGTS_PREFIX_INVALID <Area>Error.ValueError Invalid replicate-weight prefix Map each prefix to the name its replicate numbers should follow, e.g. {‘w’: ‘final_w’}.
REP_WGTS_RENAME_COLLISION <Area>Error.ValueError Replicate-weight names already taken Pick another prefix, or rename or remove those columns first (sample.wrangling.rename_columns / remove_columns).
REP_WGTS_UNKNOWN_PREFIX <Area>Error.KeyError Unknown replicate-weight set Key the mapping by one of those prefixes, e.g. {…: ‘new_prefix’}.
RESERVED_COLUMN <Area>Error.ValueError Column names reserved by svy Use another name, e.g. …. If the frame came from svy (sample._data, or a file an earlier version saved), drop them, svy rebuilds them: data.drop(…).
WEIGHT_OVERWRITE <Area>Error.ValueError Weight columns cannot be overwritten Write the new values under a new name, e.g. sample.wrangling.mutate({…: …}), or rename first, sample.wrangling.rename_columns({…: …}), which carries the rename through the design and its history, then write ….

API use

Code Raised as Message Hint
ACCESSOR_OVERWRITTEN UsageWarning Accessor overwritten
DATA_NOT_POLARS UsageError.TypeError Data must be a polars DataFrame
DESIGN_GIVEN_DATA UsageError.TypeError Design does not take data Use ….
MAPPING_KEYS_MISMATCH UsageError.ValueError Empty mapping Give one entry per stratum, or a single number for all.
NAME_MOVED UnknownNameError ….… moved Use ….…, or from … import ….
PARAM_GIVEN_TWICE UsageError.TypeError Argument given twice Give n as a pair, or n as n1 with alloc_ratio, not both.
UNKNOWN_ARGUMENT UsageError.TypeError Unknown argument
UNKNOWN_NAME UnknownNameError ….… does not exist

Design

Code Raised as Message Hint
ADJUSTMENT_NOT_CREDITED DesignWarning Weight adjustment not credited
CASE_ID_INVALID DesignError.ValueError Invalid case_id A case is one row per wave: if these are household rows, the person-level file needs a person id.
COMBINE_COLUMNS_NULL_FILLED DesignWarning Columns null-filled
COMBINE_MIXED_DESIGN DesignWarning Waves declare different designs
DESIGN_FIELDS_REMOVED DesignWarning Design fields removed
DESIGN_FROZEN DesignError.AttributeError Design is frozen
EMPTY_IN_VALUES DesignError.ValueError Empty membership filter
FILTER_BUILD_FAILED DesignError.RuntimeError Failed to build filter
INVALID_N DesignError.ValueError Invalid row count
INVALID_OFFSET DesignError.ValueError Invalid offset
INVALID_ORDER_TYPE DesignError.TypeError Invalid order type
INVALID_SINGLETON_RULE DesignError.ValueError Invalid singleton rule
INVALID_WEIGHT_ROWS_REMOVED DesignWarning Rows removed due to invalid weights
JACKKNIFE_COEFS_UNAVAILABLE DesignWarning JKn coefficients cannot be derived
JACKKNIFE_KIND_UNSPECIFIED DesignWarning Jackknife kind … does not match the units Expected when the frame is a subset of what the replicate weights were built from. Otherwise the kind is probably wrong.
MISSING_FILTER_COLUMN DesignError.KeyError Filter column not found
MISSING_SORT_COLUMNS DesignError.KeyError Sort column(s) not found
PANEL_SMALL_OVERLAP DesignWarning Small panel overlap
PANEL_UNITS_LOST DesignWarning Design units lost between waves
REP_WGTS_COUNT_MISMATCH DesignError.ValueError Replicate count does not match the columns
REP_WGTS_RENAME_INVALID DesignError.ValueError Replicate-weight rename Rename all replicate columns together with a common new prefix, keeping the numeric suffixes.
REP_WGTS_RESET DesignWarning Replicate weights removed
REP_WGTS_WGT_MISMATCH DesignError.ValueError Replicate weights for another weight Pass replicate weights built from …, or leave rep_wgts.wgt unset to pair them with the design’s weight.
SINGLETON_WITHOUT_STRATUM DesignError.ValueError Singleton rule without strata Declare stratum= with the singleton rule, or drop the rule.
SLICE_FAILED DesignError.RuntimeError Slicing failed Requested more rows than available after filtering and offset.
TAYLOR_WITHOUT_DESIGN DesignWarning Taylor variance on a design with no stratum or psu Pass method=‘replication’ to use the replicate weights, or declare stratum/psu if the frame carries them. Pass method=‘taylor’ explicitly to keep this variance.
TO_CODE_DATA_NOT_PARQUET DesignError.ValueError to_code reads parquet only Save the data with svy.io.write_parquet(sample, ‘survey.parquet’) and pass that path, or pass nothing and define data yourself.
UNSUPPORTED_FILTER_EXPR DesignError.TypeError Unsupported filter element
UNSUPPORTED_WHERE DesignError.TypeError Unsupported filter
WAVE_LABELS_UNORDERED DesignWarning Wave labels out of order
WGT_ADJUSTMENT_MISMATCH DesignError.ValueError Weight adjustment for another weight

Singleton

Code Raised as Message Hint
DOMAIN_SINGLETON SingletonError.ValueError Strata with a single PSU in a domain sample.domain_singletons(by=…, where=…) lists them.
DOMAIN_SINGLETON_PSU SingletonWarning Strata with a single PSU in a domain
NO_MERGE_TARGETS SingletonError.ValueError No valid merge targets
SINGLETONS_DETECTED SingletonWarning Singleton PSUs/strata detected after filtering
SINGLETON_API_REMOVED SingletonAPIRemoved sample.singleton was removed sample.singleton.center() is now svy.Design(…, singleton=“center”); certainty() is “self_representing”.
SINGLETON_COLLAPSE_CHANGED SingletonWarning Singleton collapse changed
SINGLETON_MAPPING_UNUSED SingletonWarning Collapse mapping entries not used
SINGLETON_ORDER_BY_INVALID SingletonError.KeyError, SingletonError.ValueError … names columns not in the data … names columns constant within each stratum, e.g. ….
SINGLETON_RULE_CLEARED SingletonWarning Singleton rule removed
SINGLETON_RULE_UNRESOLVED SingletonError.ValueError The singleton rule cannot be applied Change the rule with sample.update_design(singleton=…).
SINGLETON_SKIPPED_IN_REPLICATES SingletonWarning Singleton strata contribute nothing to the replicates
SINGLETON_STRATUM_AMBIGUOUS SingletonError.ValueError Ambiguous stratum Name it by its columns’ values.
SINGLETON_TARGET_MISSING SingletonError.KeyError, SingletonError.ValueError Collapse target not in the data Update the mapping: sample.update_design(singleton=svy.Singleton(“collapse”, using={…})).
SINGLETON_TARGET_OUTSIDE_WITHIN SingletonError.ValueError Collapse target outside within Map each singleton to a stratum with the same …, or leave within out of the rule.
SINGLETON_TARGET_SINGLETON SingletonError.ValueError Collapse target is a singleton Map each singleton stratum to a stratum with two or more PSUs.
SINGLETON_UNMAPPED SingletonError.ValueError Singletons missing from the collapse mapping Add them to the mapping (sample.singletons lists the singletons), or collapse with a strategy: svy.Singleton(“collapse”, using=“smallest”).
SINGLETON_WITHIN_INVALID SingletonError.KeyError, SingletonError.ValueError … names columns not in the data … names columns constant within each stratum, e.g. ….

Estimation

Code Raised as Message Hint
ASSOC_COLS_INVALID EstimationError.ValueError Invalid cols argument
CONTRAST_COV_SHAPE EstimationError.ValueError Covariance shape mismatch
CONTRAST_DIV_ZERO EstimationError.ValueError Division by a zero estimate
CONTRAST_EMPTY EstimationError.ValueError Nothing to contrast
CONTRAST_INVALID_SPEC EstimationError.ValueError Invalid contrast specification
CONTRAST_LIST_AMBIGUOUS EstimationError.ValueError contrast() needs a single result
CONTRAST_LOG_DOMAIN EstimationError.ValueError Log of a non-positive estimate
CONTRAST_MIXED_SPEC EstimationError.ValueError Mixed contrast specification
CONTRAST_NONLINEAR EstimationError.ValueError Not a linear contrast
CONTRAST_NO_COVARIANCE EstimationError.ValueError No between-estimate covariance on this result
CONTRAST_NO_DF EstimationError.ValueError No degrees of freedom on this result
CONTRAST_OPERAND_INVALID EstimationError.TypeError Invalid contrast operand
CONTRAST_UNKNOWN_KEY EstimationError.KeyError Unknown contrast key
CONTRAST_UNSUPPORTED_PARAM EstimationError.ValueError Contrasts are not defined for quantiles
CORR_KIND_NOT_IMPLEMENTED EstimationError.NotImplementedError Correlation kind … is not supported yet Use kind=‘pearson’, or track the issue for rank-based support.
CORR_KIND_UNKNOWN EstimationError.ValueError Unknown correlation kind … Use kind=‘pearson’.
CORR_METHOD_IS_KIND EstimationError.ValueError … is a correlation kind, not a variance method Use kind=… instead of method=….
DEFF_BOOL_REJECTED EstimationError.TypeError deff no longer accepts …
DEFF_NOT_COMPUTABLE EstimationError.ValueError Design effect is not computable for this design Use deff=‘wr’, which compares against a with-replacement reference, needs no population size and is unaffected by rescaled weights.
DEFF_REFERENCE_UNKNOWN EstimationError.ValueError Unknown deff reference … Use deff=‘wor’ for Kish’s design effect, deff=‘wr’ for deft^2.
ESTD_KEY_MISSING EstimationError.TypeError No estimand named Name the result row, e.g. estd(‘urban’) or estd(‘urban’, ‘female’) for a by= cross; r.keys() lists them.
FPC_INVALID_VALUES EstimationError.ValueError Invalid FPC values Use population counts (e.g., 500), not sampling fractions (e.g., 0.2).
FPC_NOT_CONSTANT EstimationError.ValueError FPC not constant within PSUs Ensure each row in a PSU has the same SSU population size value.
FPC_POP_LT_SAMPLE EstimationError.ValueError FPC population size < sample size SSU population size M must be >= the number of sampled SSUs m in every PSU.
LABEL_COLUMN_CLASH EstimationError.ValueError Label column clashes with a variable Rename the variable, or pass use_labels=False.
PAIR_COLUMN_CLASH EstimationError.ValueError Domain variable clashes with the pair columns Rename the domain variable before estimating.
PROP_CI_BOUNDARY EstimationWarning Confidence interval undefined at a proportion of 0 or 1 Use …, which gives a one-sided interval at 0 and 1 (Korn & Graubard 1998; NCHS data presentation standards).
PROP_NOT_CATEGORICAL EstimationError.TypeError Not a categorical variable prop() takes a categorical or indicator variable (0/1 or discrete codes); mean() estimates the average of a continuous one.
QUANTILE_P_INVALID EstimationError.ValueError Invalid probabilities Give distinct probabilities strictly between 0 and 1, e.g. p=[0.25, 0.75].
RATIO_LENGTH_MISMATCH EstimationError.ValueError Mismatched numerator/denominator lengths Pass equal-length y and x lists, or a scalar for one side.
REP_COEFS_LENGTH_MISMATCH EstimationError.ValueError … length mismatch
RESULT_COLUMN_CLASH EstimationError.ValueError Variable clashes with a result column Rename the variable before the analysis.
SCALE_LENGTH_MISMATCH EstimationError.ValueError … length mismatch
TABLE_FROZEN EstimationError.AttributeError Table is frozen Use .update(…) to create a modified copy.
TEST_GROUP_COUNT EstimationError.RuntimeError Wrong number of groups A t-test compares two levels of group= and a rank test at least two, within the analysis domain; where= selects them.

Model

Code Raised as Message Hint
CAT_REF_AMBIGUOUS ModelError.ValueError Reference label is ambiguous Pass the code of the reference level instead.
CAT_REF_NOT_FOUND ModelError.ValueError Reference level not found Check the level’s value and dtype (e.g. 1 vs ‘1’), or pass one of the column’s value labels.
DOMAIN_VIOLATION ModelError.ValueError Distribution domain violation
DUPLICATE_TERM ModelError.ValueError Duplicate model term List each predictor once.
EXPONENTIATE_NOT_RATIO ModelError.ValueError Not a ratio Leave exponentiate=False for this link; the coefficients are on its own scale.
GLM_NOT_CONVERGED ModelWarning GLM did not converge
GLM_NO_COVARIANCE ModelError.ValueError No covariance on this fit
GLM_NO_DF ModelError.ValueError No degrees of freedom on this fit
GLM_NO_OBSERVATIONS ModelError.ValueError No observations to fit Check the where clause and the weight column; rows with a missing predictor are kept with weight zero and do not count here.
GLM_ROWS_DROPPED ModelWarning Rows with invalid weights dropped
GLM_SEPARATION ModelWarning Outcome separated: some coefficients are not identified
GLM_TERM_DROPPED ModelWarning Categorical term dropped
GLM_UNKNOWN_TERM ModelError.KeyError Unknown model term
INSUFFICIENT_OBSERVATIONS ModelError.ValueError GLM cannot be fitted
LINK_NOT_ADMITTED ModelError.ValueError Link not admitted Use one of: ….
MARGINS_AT_CELL ModelError.ValueError Cell does not match its key e.g. …, or None for every fitted level.
MARGINS_AT_CONFLICT ModelError.ValueError Effect variable fixed by at= Drop … from at=, or drop variables= for its predictive margins.
MARGINS_AT_KEY ModelError.ValueError Invalid at= key Use “x” for one variable or (“a”, “b”) for a joint margin.
MARGINS_AT_LEVELS ModelError.ValueError No levels to enumerate List the values of … to use.
MARGINS_AT_TYPE ModelError.TypeError at= must be a dict e.g. at={“x”: [1, 2]} or at={(“a”, “b”): [(“a1”, “b1”), (“a2”, “b2”)]}
MARGINS_NO_EFFECT ModelError.ValueError No marginal effect
MARGINS_UNKNOWN_VARIABLE ModelError.ValueError Variable not in the model
MODEL_NOT_FITTED ModelError.ValueError Model not fitted
NB_REPLICATE_THETA ModelError.ValueError Replicate variance needs a known dispersion Estimate theta once on the full sample, then pass it.
NB_THETA_INVALID ModelError.ValueError GLM cannot be fitted
NB_THETA_UNDEFINED ModelError.ValueError GLM cannot be fitted
NON_FINITE_INPUT ModelError.ValueError GLM cannot be fitted
PRED_COLUMN_MISSING ModelError.KeyError, ModelError.ValueError Column missing from prediction data Provide every predictor the model was fitted on.
PRED_UNKNOWN_LEVEL ModelError.ValueError Unknown level in prediction data Drop those rows, or refit with the level present.
RANK_DEFICIENT ModelError.ValueError GLM cannot be fitted
REPLICATE_FIT_FAILED ModelError.RuntimeError Replicate GLM fit failed

Weighting

Code Raised as Message Hint
AUX_NA WeightingError.ValueError Missing values in continuous auxiliary Impute or drop missing values (e.g. wrangling.fill_null) before calibrating on this auxiliary.
AUX_TERMS_EMPTY WeightingError.ValueError No auxiliaries Name at least one auxiliary, e.g. x=[‘income’, Cat(‘region’)].
BOUNDS_EXCEEDED WeightingError.ValueError Adjustment factor out of bounds Widen the bounds, relax the margins, or collapse sparse levels.
BY_NA WeightingError.ValueError Missing values in by columns Fill or drop the nulls first, or leave those rows out with where=.
CALIBRATION_NOT_MET WeightingError.RuntimeError Controls not met Check for collinear auxiliaries (one implied by others), controls that contradict each other, or a domain too small for its auxiliaries.
CELLS_BY_OVERLAP WeightingError.ValueError Same column in by= and cells= Drop … from one of them.
CELLS_NULL_UNADJUSTED WeightingWarning Rows with a null left unadjusted Fill the nulls (wrangling.fill_null) or recode them to a level to adjust these rows, or leave them out with where= to make the choice explicit.
CELLS_REQUIRED WeightingError.ValueError cells= is required
COLUMNS_EMPTY WeightingError.ValueError No columns named Pass …=None for no grouping, or name at least one column.
CONTROLS_ALL_ZERO WeightingError.ValueError Targets are all zero At least one level needs a positive target.
CONTROLS_CONFLICT WeightingError.ValueError Both controls and shares controls= sets the totals; shares= fixes the composition and keeps the total.
CONTROLS_KEYS_MISMATCH WeightingError.ValueError Target keys do not match the data
CONTROLS_KEY_AMBIGUOUS WeightingError.ValueError Target key matches several levels Key it by the level’s own value, e.g. … instead of ….
CONTROLS_KEY_DUPLICATE WeightingError.ValueError Two keys name the same level Keep one entry for ….
CONTROLS_MISSING WeightingError.ValueError No targets controls= sets the totals; shares= fixes the composition and keeps the total.
CONTROLS_SCALAR_FOR_CELLS WeightingError.ValueError One number for several cells Pass one entry per cell, e.g. …=…, or use shares= to fix the composition, or drop cells= to set the grand total.
CONTROLS_TYPE_INVALID WeightingError.TypeError Targets have the wrong type
CONTROLS_VALUE_INVALID WeightingError.ValueError Invalid target values
DOMAIN_LEVELS_PARTIAL WeightingWarning Domains missing some levels Collapse sparse levels of the composition axis, or accept that these domains follow a different standard.
DOMAIN_SKIPPED WeightingWarning Domain skipped — cell too small Increase min_cell_size or combine small domains.
FACTOR_CONFLICT WeightingError.ValueError factor= combined with targets Call normalize(factor=…) alone, or drop factor= and give targets.
INSUFFICIENT_PSU WeightingError.ValueError Insufficient PSUs per stratum Combine small strata or check design specification.
MARGINS_DISAGREE WeightingError.ValueError Margins disagree on the total Every margin must sum to the same total (e.g. scale each to …, the total of …), or pass shares= to have them normalized against one grand total.
MARGIN_NA WeightingError.ValueError Null values in raking column Drop or impute missing values before raking, or leave those rows out with where=.
NEGATIVE_WEIGHTS WeightingError.ValueError Negative weights found Remove or correct negative weights before trimming.
NOT_SUPPORTED WeightingError.NotImplementedError Not supported yet
NO_RESPONDENTS WeightingError.ValueError Class without respondents Collapse each such class into a neighbouring one, or use coarser cells.
NO_ROWS_IN_SCOPE WeightingError.ValueError Nothing to adjust Fill the nulls (wrangling.fill_null) or choose other cells.
ODD_PSU_COUNT WeightingError.ValueError BRR needs 2 PSUs per variance stratum create_jk_wgts(paired=True) pairs these strata itself and absorbs an odd count into a triplet. BRR cannot: its balanced half-samples need exactly 2 PSUs per variance stratum. If BRR is required, fix every stratum listed, not just one – drop or combine a PSU so each count is even.
PANEL_SCOPE_NOT_WAVES WeightingWarning Missing-in-scope rule skipped Scope one or more whole waves, e.g. where=col(…) == 2, to apply it.
PSU_REQUIRED WeightingError.ValueError PSU required Pass psu=, or set it on the Design.
REF_LEVEL_UNKNOWN WeightingError.ValueError Reference level not found Use one of ….
REPLICATE_NO_RESPONDENTS WeightingWarning Replicates lost nonrespondent weight Collapse small classes so each replicate keeps respondents in every class.
RESP_MAPPING_CONFLICT WeightingError.ValueError A status is mapped twice List each value under one of rr, nr, in, uk only.
RESP_MAPPING_KEY_INVALID WeightingError.ValueError Unknown response status code Key resp_mapping by rr, nr, in or uk, e.g. {‘rr’: 1, ‘nr’: [2, 3]}.
RESP_STATUS_UNKNOWN WeightingError.ValueError Unknown response statuses Map each value to rr (respondent), nr (nonrespondent), in (ineligible) or uk (unknown), e.g. resp_mapping=… if they are nonrespondents.
SHAPE_MISMATCH WeightingError.ValueError Shape mismatch Build aux_vars from this sample’s data, one row per record.
TERM_INVALID WeightingError.ValueError Unsupported term Name a continuous auxiliary by its column, a categorical one with Cat(…).
THRESHOLD_INVALID WeightingError Invalid trimming threshold A number is an absolute bound; for a quantile use svy.Threshold.quantile(p).
TRIM_BOUNDS_MISSING WeightingError.ValueError No trimming bounds e.g. upper=Threshold.quantile(0.99), or lower=0.5.
TRIM_INFEASIBLE WeightingError.ValueError Trimming bounds cannot keep the total Use …; or pass redistribute=False to let the total change.
WEIGHTING_NOT_CONVERGED WeightingError.RuntimeError, WeightingWarning Did not converge Increase TrimConfig.max_iter or use a less restrictive trim threshold.
WEIGHT_ADJ_AUDIT WeightingWarning Trim audit — domain …
WEIGHT_SUM_CHANGED WeightingWarning Total weight sum changed Use redistribute=True to avoid changing the weighted sample size.
WGT_MISSING WeightingError.ValueError No sample weight sample.update_design(wgt=‘’).
WGT_NAME_EXISTS WeightingError.ValueError Weight name already used e.g. …(…, wgt_name=…).
WHERE_INVALID WeightingError.ValueError where cannot be evaluated Check that every column referenced by where exists.
ZERO_WEIGHT WeightingWarning Zero-weight units excluded from trimming

Selection

Code Raised as Message Hint
ALLOCATION_CAPPED SelectionWarning Allocation reduced by the frame sizes
ALLOCATION_EXCEEDS_FRAME SelectionWarning Allocation capped at the frame size
ALLOCATION_INVALID SelectionError.ValueError Allocation not possible
ALLOCATION_MIN_N_IGNORED SelectionWarning min_n not honored
GROUP_LABELS_LENGTH SelectionError.ValueError Wrong number of group labels
INFEASIBLE_DESIGN SelectionError.ValueError Infeasible design Use a negative delta for non-inferiority, or a margin below the expected difference.
INVALID_STAGE SelectionError.ValueError Invalid stage
MULTISTAGE_ALREADY_SELECTED SelectionError.ValueError Frame already has selection weights Start from the frame, or add a stage to a drawn sample with add_stage.
MULTISTAGE_COLUMN_MISSING SelectionError.KeyError Stage column not in the frame
MULTISTAGE_COLUMN_TAKEN SelectionError.ValueError Output column already in the frame Rename or drop them first.
MULTISTAGE_NOT_CONSTANT SelectionError.ValueError Value varies within a unit
MULTISTAGE_N_MISSING SelectionError.ValueError Stage 1 n= does not match the strata
POWER_N_EXCEEDS_POPULATION SelectionError.ValueError Sample larger than the population n counts the units selected; it cannot give more respondents than the population has.
SELECTION_GROUP_EMPTY SelectionWarning Group with no frame units
SELECTION_MOS_NONPOSITIVE SelectionWarning Units with MOS <= 0
SELECTION_N_EXCEEDS_GROUP SelectionError.ValueError, SelectionWarning Sample size exceeds the group Use wr=True for with-replacement sampling, or reduce n.
SELECTION_N_INVALID SelectionError.ValueError Invalid sample size
SELECTION_STRATUM_EMPTY SelectionWarning Stratum with no frame units
SIZE_METHOD_MARGIN SelectionError.ValueError Method does not take a margin Use method=‘wald’ for a non-inferiority or equivalence margin, or delta=0.
SIZE_NO_VARIANCE SelectionError.ValueError No variance left in the change Use a correlation below 1, or a partial overlap.
STAGE_PSUS_UNMATCHED SelectionWarning Stage-1 PSUs without next-stage records
STAGE_TAKES_ALL SelectionWarning Stage takes every unit of some parents

Label

Code Raised as Message Hint
COMBINE_CATALOGS_RESOLVED LabelWarning Labelling catalogs resolved
COMBINE_LABELS_CONFLICT LabelWarning Value labels dropped
COMBINE_MTYPE_CONFLICT LabelWarning Measurement types disagree
DATA_VALUE_NOT_LABELED LabelWarning Data values without labels Add labels for these values or ignore this warning.
LABEL_API_REMOVED LabelAPIRemoved … was removed meta.var_labels[var] gives the variable label and meta.value_labels[var] the code-to-label mapping; set them with set_var_label(s) and set_value_labels.
LABEL_DUPLICATE_CODE LabelError.ValueError Duplicate category code Remove the duplicate, or merge the two entries.
LABEL_KEY_NOT_IN_DATA LabelWarning Category labels for values not in data These labels will be stored but won’t match any current data values.
LABEL_NAN_KEY LabelError.ValueError NaN key is not allowed
LABEL_READ_ONLY LabelsReadOnly … is read-only
LABEL_SCHEME_EXISTS LabelError.ValueError Scheme already exists
LABEL_SERIALIZATION_ERROR LabelError.ValueError Label catalog serialization failed
LABEL_SOURCE_CONFLICT LabelError.ValueError Two sources of value labels Give the labels inline or point to a catalog scheme, not both.
LABEL_UNKNOWN_SCHEME LabelError.KeyError Scheme not found
LABEL_VARIABLE_UNKNOWN LabelError.KeyError No metadata for the variable store.get(var) returns None instead; store.variables lists what is held.

Data

Code Raised as Message Hint
AMBIGUOUS_BINS DataError.ValueError Ambiguous bin specification Use ‘bins’ for explicit edges or ‘percentiles’ to compute from data.
CAST_DTYPE_REQUIRED DataError.TypeError dtype required when cols is not a mapping
CAST_FAILED DataError.ValueError Cast failed strict=False turns values that do not convert into nulls.
CAST_TRUNCATION DataError.ValueError Lossy float-to-integer cast Round explicitly first (e.g. .round(0)) or pass strict=False to allow truncation.
CAST_UNKNOWN_DTYPE DataError.ValueError Unknown dtype name Pass a polars dtype for parameterised types (e.g. pl.Datetime(time_zone=…)).
COLUMN_NOT_NUMERIC DataError.TypeError Column is not numeric prop() and tabulate() take categorical variables; sample.wrangling.cast() converts numbers stored as text.
DROP_PROTECTED_COLUMNS DataError.ValueError Cannot remove design-referenced columns Pass force=True to drop them and automatically clean the design.
FILTER_FAILED DataError.RuntimeError Filter failed
JOIN_COLUMN_EXISTS DataError.ValueError Join would overwrite columns Name them on the way in, e.g. into={“region”: “region_hh”}, or pass suffix=“_hh”.
JOIN_INTO_NOT_BROUGHT DataError.ValueError Naming a column that is not brought in into names columns of the other side. Add them to cols, or leave cols out.
JOIN_KEY_IN_COLS DataError.ValueError A key cannot also be brought in The key is already on this sample; leave it out of cols.
JOIN_KEY_NOT_UNIQUE DataError.ValueError Join key repeats on the other side Each record here must match at most one record there. Deduplicate first.
JOIN_KEY_TYPE_MISMATCH DataError.TypeError Join key types do not match Cast one side first so both hold the same kind of value.
JOIN_UNMATCHED DataError.ValueError, DataWarning Records without a match Pass on_unmatched=“warn” to keep them with nulls.
KEEP_DROPS_PROTECTED DataError.ValueError Keeping these columns would remove design-referenced columns Pass force=True to proceed; the design will be cleaned automatically.
LABELS_LENGTH_MISMATCH DataError.ValueError Label count mismatch
LAG_NAME_MISMATCH DataError.ValueError name/cols length mismatch
MEAN_FILL_INT_CAST DataWarning Integer column(s) cast to Float64 for mean fill
MISSING_BINS DataError.ValueError No bin specification Use ‘bins’ for explicit edges or ‘percentiles’ to compute from data.
MISSING_LABELS DataError.ValueError No labels provided Pass labels={‘var’: ‘Label’} and/or categories={‘var’: {val: ‘text’}}.
MISSING_VALUES DataError.ValueError Missing values
MUTATE_COMPILE_FAILED DataError.RuntimeError Column transformation failed Check names, syntax, that array/series lengths match n_rows, and finalize when/then with .otherwise(…).
MUTATE_DEPENDENCY_ERROR DataError.ValueError Dependency resolution failed Split into multiple mutate() calls or break the circular reference.
MUTATE_WITH_COLUMNS_FAILED DataError.RuntimeError Column transformation failed
NULL_PREDICATE_ROWS_DROPPED DataWarning Rows with null filter predicate dropped fill_null the referenced columns first to keep these rows.
RENAME_FAILED DataError.RuntimeError Rename failed
RENAME_FORBIDDEN DataError.ValueError Reserved column names cannot be renamed These names are svy’s own; rename to or from another name.
SINGLETONS_AFTER_FILTER DataError.ValueError Singletons detected after filtering Declare a rule for them: sample.update_design(singleton=svy.Singleton(“center”)).
WEIGHT_NOT_NUMERIC DataError.TypeError, DataError.ValueError Weight column is not numeric Cast it first, e.g. pl.col(…).cast(pl.Float64).

Files

Code Raised as Message Hint
ARCHIVE_MEMBER_NOT_FOUND IoError.FileNotFoundError No readable file in archive Check the archive’s contents, or extract the data file and read it directly.
FILE_NOT_FOUND IoError.FileNotFoundError File not found
IO_BLANK_ROWS_LOST IoWarning Blank rows will not read back
IO_LABELS_NOT_WRITTEN IoWarning Value labels not written
IO_OPTION_IGNORED IoWarning Option ignored
IO_READ_FAILED IoError Unexpected read failure
IO_TEMPORAL_AS_NUMBER IoWarning Times written as numbers
IO_WRITE_FAILED IoError Unexpected write failure
NOT_A_FILE IoError.OSError Not a file
PERMISSION_DENIED IoError.PermissionError Permission denied
READSTAT_PARSE_FAILED IoError.ValueError … parse error

Dataset

Code Raised as Message Hint
BUNDLED_UNAVAILABLE DatasetError.FileNotFoundError Bundled dataset unavailable
CATALOG_BAD_STATUS DatasetError.OSError Catalog request failed
CATALOG_UNREACHABLE DatasetError.OSError Catalog unreachable
DATASET_BUNDLED_SUBSET DatasetWarning Using the bundled subset
DATASET_CATALOG_OFFLINE DatasetWarning Dataset catalog unreachable
DATASET_DOWNLOAD_FAILED DatasetError.OSError Dataset download failed
DATASET_INSECURE_URL DatasetError.ValueError Insecure dataset download URL
DATASET_INVALID_SLUG DatasetError.ValueError Invalid dataset slug
DATASET_NOT_BUNDLED DatasetError.KeyError Dataset not bundled
DATASET_NOT_FOUND DatasetError.KeyError Dataset not found
DATASET_SHA_MISMATCH DatasetError.ValueError Dataset integrity check failed
REMOTE_UNAVAILABLE DatasetError.ImportError Online dataset catalog unavailable

Serialization

Code Raised as Message Hint
PAYLOAD_MISSING_KIND SerializationError.ValueError Payload missing ‘kind’
PAYLOAD_NOT_A_DESIGN SerializationError.ValueError Not a design payload
PAYLOAD_NO_TABLE SerializationError.ValueError No table for this payload
PAYLOAD_UNKNOWN_KIND SerializationError.ValueError Unknown payload kind
SINGLETON_RULE_NOT_SAVABLE SerializationError.ValueError Cannot save the singleton rule Use an int seed, e.g. svy.Singleton(‘collapse’, rstate=42).
UNSUPPORTED_RESULT_TYPE SerializationError.TypeError No serializer registered

Experimental

Code Raised as Message Hint
EXPERIMENTAL ExperimentalWarning Experimental method Silence it with warnings.filterwarnings(‘ignore’, category=svy.errors.ExperimentalWarning).

Defaults

Code Raised as Message Hint
DATASET_ERROR DatasetError No code given
DATA_ERROR DataError No code given
DESIGN_ERROR DesignError No code given
ESTIMATION_ERROR EstimationError No code given
IO_ERROR IoError No code given
LABEL_ERROR LabelError No code given
MODEL_ERROR ModelError No code given
SELECTION_ERROR SelectionError No code given
SERIALIZATION_ERROR SerializationError No code given
SINGLETON_ERROR SingletonError, SingletonError.ValueError No code given sample.update_design(singleton=svy.Singleton(“center”)), or svy.Design(…, singleton=“center”) when building the sample.
SVY_ERROR SvyError No code given
SVY_WARNING SvyWarning No code given
SVY_WARNINGS_ERROR SvyWarningsError No code given
USAGE_ERROR UsageError No code given
WEIGHTING_ERROR WeightingError No code given