Skip to content

Series.map(func: Series) is broken in most cases #12426

Closed

Description

@crusaderky

pd.Series.map and pd.Index.map when the argument is a Series have the issue that the output dtype can change dynamically.
This is why these methods in Dask expose a meta= argument and warn loudly if the user does not explicitly provide it.

Expected behaviour

As long as the user provides the same meta= that would (could) actually be produced by Pandas, then the output dd.Series.dtype, the partitions' dtypes and the computed dtype all match the provided dtype. compute() crashes loudly and early if the meta dtype cannot accommodate the actual data (like converting an array with NaNs or N/As to non-nullable numpy integers).

Actual behaviour

  • dd.Index does not support N/A
  • in some cases, the output's meta dtype does not match the one passed to the function
  • in many cases, compute() crashes
  • even in the trivial use case where pandas does not change the dtype (pd.Series.map(x).dytpe == x.dtype), there are small dtype mismatches in arrow and pandas dtypes between pandas and Dask

Reproducer

These issues are tested and XFAIL'ed in main:

See also

Activity

  1. added
    needs triage
    on May 29, 2026
  2. added
    bug
    p2
    and removed
    needs triage
    on May 29, 2026
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

    bugdataframep2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions