Skip to content

fix(data): pass non-string column labels to PreTab by position - #512

Merged
mkumar73 merged 3 commits into
mainfrom
fix/integer-column-labels
Oct 30, 2026
Merged

mkumar73 merged 3 commits into
mainfrom
fix/integer-column-labels

Conversation

@ChrisW09

@ChrisW09 ChrisW09 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #507

Problem

PreTab detects column types by label but passes the labels to ColumnTransformer, which treats integer specifiers as positions. A DataFrame with integer labels other than 0..n-1 in order therefore crashed fit(), or matched columns with the wrong preprocessing. The common case is a headerless CSV after drop(columns=0).

Fix

deeptab/data/datamodule.py adds _positional_columns(). DataFrames whose labels aren't all strings, and aren't already 0..n-1 in order, are relabelled 0..n-1 in column order before PreTab sees them, both for fitting and for every transform. This matches how DeepTab already treats such frames: feature_names_in_ is only recorded for string names, and prediction input is checked by column count. String-named frames and NumPy input are unchanged.

Tests

  • tests/data/test_datamodule.py::test_positional_columns_relabels_only_non_positional_integer_labels
  • tests/integration/test_estimator_input_validation.py::TestIntegerColumnLabels: a frame after drop(columns=0), and reordered integer labels with a string categorical column. Both give the same categories and predictions as the same data with string column names.

All of these fail on main and pass with this change.

Docs

docs/core_concepts/sklearn_api.md ("Accepted Inputs") now says that a DataFrame whose column labels aren't all strings is treated like an array: its columns are used by position, and feature_names_in_ is not set.

Checks

  • just test: 3243 passed, 46 skipped, 28 xfailed; coverage 91.30% (re-run after the docs commit)
  • just docs: build succeeded (warnings treated as errors)
  • just check: all hooks passed (ruff, prettier, pyright)

ChrisW09 and others added 3 commits October 21, 2026 16:28
PreTab detects column types by label but hands the labels to
ColumnTransformer, which treats integer specifiers as positions. Integer
labels that are not 0..n-1 in order (e.g. a headerless frame after
drop(columns=0)) therefore crashed fit() or matched columns with the wrong
preprocessing.

DeepTab already treats non-string labels positionally (feature_names_in_
is only recorded for string names), so relabel such frames 0..n-1 in
column order before they reach the preprocessor, for fitting and for
every transform.

Fixes #507

@mkumar73 mkumar73 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Changes look good.

@mkumar73
mkumar73 merged commit d53acd8 into main Oct 30, 2026
35 checks passed
@mkumar73
mkumar73 deleted the fix/integer-column-labels branch October 30, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] DataFrames with integer column labels other than 0..n-1 crash fit() or get the wrong preprocessing per column

2 participants