Skip to content

[Python] Compatibility with numpy 2.0 (removal of np.unicode_) #37574

Closed

Description

@martinfleis

Describe the bug, including details regarding any error messages, version, and platform.

Numpy has deprecated np.unicode_ and removed it in an upcoming 2.0 release. Current nightly builds do not have np.unicode_ which results in an incompatibility between pyarrow main and numpy main due to this mapping:

_numpy_logical_type_map = {
np.bool_: 'bool',
np.int8: 'int8',
np.int16: 'int16',
np.int32: 'int32',
np.int64: 'int64',
np.uint8: 'uint8',
np.uint16: 'uint16',
np.uint32: 'uint32',
np.uint64: 'uint64',
np.float32: 'float32',
np.float64: 'float64',
'datetime64[D]': 'date',
np.unicode_: 'string',
np.bytes_: 'bytes',
}

and possibly would also fail on this one

_pandas_logical_type_map = {
'date': 'datetime64[D]',
'datetime': 'datetime64[ns]',
'datetimetz': 'datetime64[ns]',
'unicode': np.unicode_,
'bytes': np.bytes_,
'string': np.str_,
'integer': np.int64,
'floating': np.float64,
'empty': np.object_,
}

numpy now raises AttributeError: np.unicode_was removed in the NumPy 2.0 release. Usenp.str_ instead. See the full traceback in the geopandas CI.

Component(s)

Python

Activity

  1. AlenkaF commented on Sep 6, 2023

    @AlenkaF
    Member

    Thank you for bringing this to our attention @martinfleis !

  2. added this to the 14.0.0 milestone on Sep 6, 2023
  3. changed the title [-]Compatibility with numpy 2.0 (removal of np.unicode_)[/-] [+][Python] Compatibility with numpy 2.0 (removal of np.unicode_)[/+] on Sep 6, 2023
  4. added
    Priority: Blocker
    on Sep 29, 2023
  5. graingert commented on Oct 5, 2023

    @graingert
    Contributor

    it looks like the nightly CI job is using https://pypi.anaconda.org/scipy-wheels-nightly/simple as opposed to https://pypi.anaconda.org/scientific-python-nightly-wheels/simple per https://scientific-python.org/specs/spec-0004/ so didn't get the nightly update to numpy v2

    pip install --extra-index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple --pre numpy

  6. graingert commented on Oct 5, 2023

    @graingert
    Contributor

    There's a handful of other removals where pyarrow is impacted: np.sctypes and np.NaN

  7. assigned and unassigned on Oct 5, 2023
  8. added a commit that references this issue on Oct 5, 2023
  9. added a commit that references this issue on Nov 13, 2023
  10. added a commit that references this issue on Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Component: PythonPriority: BlockerType: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions