Skip to content

Commit 22f75a5

Browse files
committed
Do not pin the pandas-resolved dtype of a missing str index
The dtype test asserted that _missing_index(2, "str").dtype == "str", which only holds on pandas 3: before that "str" resolves to object, so all twelve CI test jobs failed on this one assertion while the other three new tests passed. Ask pandas which dtype it resolves to instead of pinning either convention, so the test states the contract (a missing index keeps the dtype a non-missing index of that dtype would have) on both. Verified on pandas 2.1.4 and pandas 3.0.5: the focused test is RED with the old assertion and GREEN with this one, and test_multi.py is 177 passed / 31 skipped / 6 xfailed / 2 xpassed on pandas 2.1.4 and 177 passed / 31 skipped / 8 xfailed on 3.0.5. Assisted-by: Hermes Agent (deepseek-v4-flash-vision-exp)
1 parent 6a3f544 commit 22f75a5

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎dask/dataframe/tests/test_multi.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,9 @@ def test_missing_index_uses_a_dtype_that_holds_missing_values():
25812581
from dask.dataframe.multi import _missing_index
25822582

25832583
assert _missing_index(2, "str").isna().all()
2584-
assert _missing_index(2, "str").dtype == "str"
2584+
# "str" is the string extension dtype on pandas 3 and object dtype on
2585+
# pandas < 3, so ask pandas what it resolves to instead of pinning either.
2586+
assert _missing_index(2, "str").dtype == pd.Index([np.nan], dtype="str").dtype
25852587

25862588
upcast = _missing_index(2, "int64")
25872589
assert upcast.isna().all()

0 commit comments

Comments
 (0)