Skip to content

[unsupervised AI] Keep non-string object columns unchanged in from_pandas - #12626

Draft
barlowa124 wants to merge 3 commits into
dask:mainfrom
barlowa124:fix-from-pandas-mixed-object-strings-12612
Draft

barlowa124 wants to merge 3 commits into
dask:mainfrom
barlowa124:fix-from-pandas-mixed-object-strings-12612

Conversation

@barlowa124

@barlowa124 barlowa124 commented Oct 9, 2026 •

Copy link
Copy Markdown

Warning

This PR was written autonomously by an AI agent and has not been reviewed by a human yet. Maintainers should ignore it until the human author has reviewed and understood everything that the AI agent wrote and approved it.

to_pyarrow_string converts every object-dtype column to
string[pyarrow], yet object dtype holds arbitrary Python objects. A
mixed column such as ["1", 1] loses the 1 to stringification, so
isin results on dd.from_pandas differ from pandas in both
directions.

FromPandas holds the whole frame in memory, so conversion now runs
there once, gated by a values check (infer_dtype on each column and
index level). Object columns whose non-missing values are not all
strings keep their dtype. Per-partition conversion is dropped: slices
of the converted frame already agree with the meta, and a per-slice
check could make partitions disagree.

The other to_pyarrow_string callers (ArrowStringConversion, the
read_sql chunk path, assert_eq) are unchanged, since each sees a
single partition and cannot make a whole-column decision.

Verification was local, without pixi. ruff check on the touched
files reports only pre-existing findings on unmodified lines, and the
new regression test plus the dataframe/pyarrow and dask_expr
collection/core suites all pass.

to_pyarrow_string converts every object-dtype column to
string[pyarrow], which silently stringifies mixed columns like
["1", 1] (dask#12612). Since FromPandas holds the whole frame in
memory, decide convertibility there once per column and index with
a values check, so mixed data keeps its dtype and every partition
agrees with the meta.
Object-dtype columns receive placeholder values in _meta_nonempty that\npyarrow cannot type-infer. Fall back to dtype-driven inference on the\nempty meta, which types them as null fields (explicit schema overrides\nstill apply). Also update the to_numeric expectation for a mixed\ncolumn that now stays object dtype.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

     25 files  ± 0       25 suites  ±0   6h 15m 47s ⏱️ - 35m 47s
 19 915 tests + 1   18 482 ✅ + 1   1 433 💤 ±0  0 ❌ ±0 
379 373 runs  +20  332 100 ✅ +17  47 273 💤 +3  0 ❌ ±0 

Results for commit 0d00c92. ± Comparison against base commit 6ce3740.

This branch has not been deployed

No deployments
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.

isin on object-dtype columns coerces to strings: isin(['1']) matches the integer 1 (pandas does not), isin([1]) misses it

1 participant