Skip to content

Pandas 3 test failures #12225

Closed
Closed

Description

@crusaderky

The Upstream workflow is failing against pandas nightly:
https://github.com/dask/dask/actions/runs/20952839301/job/60210224683

FAILED dask/dataframe/dask_expr/tests/test_collection.py::test_map_meta - AssertionError: Series.index are different

Activity

  1. Moksha25-tech commented on Jan 18, 2026

    @Moksha25-tech

    I’ve been following the pandas-nightly workflow failures and noticed the AssertionError in test_map_meta. I have my local dev environment set up (Python 3.10) and I'd like to help investigate this.

    I'm going to try and isolate a minimal reproducible example to see if this is caused by a change in how pandas 3.0 handles index metadata or if it's a dask_expr specific logic change. I'll post my findings here shortly!

    Can you assign this issue to me?

  2. jacobtomlinson commented on Jan 22, 2026

    @jacobtomlinson
    Member

    @Moksha25-tech we don't assign issues to non-core members here. But please feel free to take a look!

    cc @TomAugspurger who has also been looking at this

  3. TomAugspurger commented on Jan 22, 2026

    @TomAugspurger
    Member

    Sorry, I forgot to push up #12243 earlier.

  4. crusaderky commented on Jan 23, 2026

    @crusaderky
    CollaboratorAuthor

    Now that pandas 3.0 final is out, main CI is failing with

    FAILED dask/dataframe/io/tests/test_parquet.py::test_filter_nonpartition_columns[pyarrow-pyarrow-True] - pandas.errors.Pandas4Warning: Constructing a Categorical with a dtype and values containing non-null entries not in that dtype's categories is deprecated and will raise in a future version.

  5. TomAugspurger commented on Jan 23, 2026

    @TomAugspurger
    Member
  6. crusaderky commented on Jan 23, 2026

    @crusaderky
    CollaboratorAuthor

    @TomAugspurger https://github.com/dask/dask/actions/runs/21276378399/job/61236740674

    Briefly looking at the test, I see a random.choice in it, which would explain why the warning only appears occasionally.

  7. nullr0ute commented on Jan 24, 2026

    @nullr0ute

    I'm seeing a couple of failures when testing the panda 3.0 upgrade in Fedora:

    FAILED dask/dataframe/dask_expr/tests/test_collection.py::test_map_meta - AssertionError: Series.index are different FAILED dask/dataframe/dask_expr/tests/test_collection.py::test_len - AssertionError: assert 100 == 10 = 2 failed, 16059 passed, 1230 skipped, 336 xfailed, 282 xpassed, 28 warnings in 446.83s (0:07:26) =

  8. TomAugspurger commented on Jan 24, 2026

    @TomAugspurger
    Member

    FAILED dask/dataframe/dask_expr/tests/test_collection.py::test_map_meta - AssertionError: Series.index are different

    I suspect that was fixed by #12243.

    I don't recall seeing dask/dataframe/dask_expr/tests/test_collection.py::test_len. Can you post a full traceback and any investigation you're able to do?

  9. crusaderky commented on Jan 24, 2026

    @crusaderky
    CollaboratorAuthor

    I don't recall seeing dask/dataframe/dask_expr/tests/test_collection.py::test_len. Can you post a full traceback and any investigation you're able to do?

    It appeared before: 🤓 #12191 (comment)

  10. Moksha25-tech commented on Jan 25, 2026

    @Moksha25-tech

    Reproduction of test_map_meta failure with pandas 3.0

    I was able to reproduce the failure locally in test_map_meta when testing against pandas 3.0.

    Environment
    Python 3.12.3
    pytest 9.0.2
    pandas 3.0
    local checkout of main

    Command used

    PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
    pytest -o addopts= \
    dask/dataframe/dask_expr/tests/test_collection.py::test_map_meta -s
    

    Debugging details
    To understand the failure, I added debug prints just before the first assertion in test_map_meta:

    print(f"DEBUG - RESULT META INDEX: {result._meta.index}")
    print(f"DEBUG - EXPECTED INDEX: {expected.index}")
    
    

    Observed output

    DEBUG - RESULT META INDEX: RangeIndex(start=0, stop=0, step=1)
    DEBUG - EXPECTED INDEX: RangeIndex(start=0, stop=100, step=1)
    

    The test then fails at:
    assert result._meta.index.equals(expected.index)

    Interpretation
    This indicates that when calling:
    df.x.map(lambda x: x + 1, meta=expected.iloc[:0])

    the resulting _meta does not preserve the index information from the provided meta. Instead, _meta.index is inferred as an empty RangeIndex(0, 0), even though the supplied meta carries the full index type.

    This reproduces the CI failure and suggests that index handling during _meta inference for Series.map has changed (or regressed) with pandas 3.0.

  11. crusaderky commented on Feb 3, 2026

    @crusaderky
    CollaboratorAuthor

    @TomAugspurger https://github.com/dask/dask/actions/runs/21276378399/job/61236740674

    Briefly looking at the test, I see a random.choice in it, which would explain why the warning only appears occasionally.

    Looking at it closer, I'm reading

    dask/dataframe/io/parquet/arrow.py:603: in read_partition
        pd.Categorical(
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    values = array([2], dtype=int32)
    categories = Index([1, 2, 3, 4], dtype='int32')
    [...]
    E           pandas.errors.Pandas4Warning: Constructing a Categorical with a dtype and values containing non-null entries not in that dtype's categories is deprecated and will raise in a future version.
    

    which makes no sense.
    I can trigger the warning with

    pd.Categorical(values = np.array([5], dtype=np.int32), categories = pd.Index([1, 2, 3, 4], dtype='int32')

    To me it smells of a race condition within pandas where different dask threads have different values and categories in their stacks and they call categories.get_indexer_for(values) in parallel, but they may share a common global state and thus interfere with each other. It reminds me of pydata/xarray#10923.

    However, just like the other issue I just linked, I'm utterly failing to reproduce it locally - either synthetically or with the dask test suite.

  12. crusaderky commented on Feb 3, 2026

    @crusaderky
    CollaboratorAuthor

    Possible root cause: race condition in pd.Index._ensure_mapping_populated: pandas-dev/pandas#63685

  13. crusaderky commented on Feb 3, 2026

    @crusaderky
    CollaboratorAuthor

    New flakiness in dask/dataframe/io/tests/test_parquet.py::test_roundtrip_partitioned_pyarrow_dataset also may have the same root cause:
    https://github.com/dask/dask/actions/runs/21628536686/job/62334916154?pr=12266

    pandas/_libs/index.pyx:168: in pandas._libs.index.IndexEngine.get_loc
        ???
    pandas/_libs/index.pyx:197: in pandas._libs.index.IndexEngine.get_loc
        ???
    pandas/_libs/hashtable_class_helper.pxi:4823: in pandas._libs.hashtable.Int32HashTable.get_item
        ???
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    >   ???
    E   KeyError: 1
    
  14. crusaderky commented on Feb 4, 2026

    @crusaderky
    CollaboratorAuthor

    I'm seeing a couple of failures when testing the panda 3.0 upgrade in Fedora:

    FAILED dask/dataframe/dask_expr/tests/test_collection.py::test_len - AssertionError: assert 100 == 10 = 2 failed, 16059 passed, 1230 skipped, 336 xfailed, 282 xpassed, 28 warnings in 446.83s (0:07:26) =`

    I've just observed this on a 3.10 environment, which is stuck on pandas 2.3.

  15. crusaderky commented on Feb 4, 2026

    @crusaderky
    CollaboratorAuthor

    This also looks caused by pandas-dev/pandas#63685:

    FAILED dask/dataframe/io/tests/test_parquet.py::test_arrow_partitioning - pandas.errors.Pandas4Warning: Constructing a Categorical with a dtype and values containing non-null entries not in that dtype's categories is deprecated and will raise in a future version.

  16. crusaderky commented on Feb 5, 2026

    @crusaderky
    CollaboratorAuthor

    I've tested pandas-dev/pandas#63783 vs. pandas git tip on 3.14 and 3.14t (#12284).

    TL;DR; the pandas PR seems to make all flakiness disappear, and I consider it a blocker to 3.14t support for dask.dataframe.

    Shared based environments

    === 3.14 ===
    mamba env create -n dask-314 -f continuous_integration/environment-3.14.yaml 
    conda activate dask-314
    mamba install pytest-repeat
    pip install . git+https://github.com/dask/distributed
    
    === 3.14t ===
    wget https://raw.githubusercontent.com/crusaderky/dask/refs/heads/314t_pandas/continuous_integration/environment-3.14t.yaml
    mamba env create -n dask-314t -f environment-3.14t.yaml
    conda activate dask-314t
    conda uninstall -y -v --force msgpack-python
    MSGPACK_PUREPYTHON=1 pip install msgpack --no-binary msgpack --no-cache --force-reinstall -v
    mamba install pytest-repeat
    pip install . git+https://github.com/dask/distributed
    

    pandas variants

    • pandas 3.0.0
      mamba install pandas=3.0.0 --force-reinstall
    • pandas git tip
      pip install git+https://github.com/pandas-dev/pandas.git@2455fb9066628929be67011d01bb62a098cdb9ea
    • BUG: Fix data races in block internals pandas-dev/pandas#63783
      pip install git+https://github.com/crusaderky/pandas.git@727c73034f9d2c63d7e0164a10c2f5e367b017c6

    Test run

    These are tests that are frequently seen to fail in our CI throughout all Python versions:

    taskset -c 0,1,2,3 python -m pytest --pyargs --count=100 \
        dask/dataframe/io/tests/test_parquet.py::test_filter_nonpartition_columns \
        dask/dataframe/io/tests/test_parquet.py::test_roundtrip_partitioned_pyarrow_dataset \
        dask/dataframe/io/tests/test_parquet.py::test_arrow_partitioning
    

    Outcome

    • Python 3.14, Pandas 3.0.0: I failed to replicate CI failures locally (probably due to much faster hardware than CI)
    • Python 3.14t, Pandas 3.0.0: 3~15% failure rate on the above tests
    • Python 3.14t, Pandas main git tip: same as 3.0.0
    • Python 3.14t, BUG: Fix data races in block internals pandas-dev/pandas#63783: all failures disappear. ⭐

    Because I failed to replicate the failures on the GIL-enabled interpreter, I cannot assertively say if these race conditions are a regression in Pandas 3.0 or if they were already there in 2.3. I can only observe from git blame that Index._ensure_mapping_populated has not been touched in at least 3 years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions