Skip to content

Conversation

@cmp0xff
Copy link
Contributor

@cmp0xff cmp0xff commented Oct 30, 2025


class CategoricalIndex(ExtensionIndex[S1], accessor.PandasDelegate):
codes: np.ndarray = ...
codes: npt.NDArray[Any] = ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np_1d_array[np.intp]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/pandas_nightly


class CategoricalIndex(ExtensionIndex[S1], accessor.PandasDelegate):
codes: np.ndarray = ...
codes: npt.NDArray[Any] = ...
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/pandas_nightly

@cmp0xff cmp0xff added the Compat pandas objects compatability with Numpy or Python functions label Nov 4, 2025
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few main issues:

  1. I think we should be consistent in the stubs in using the np_ndarray_xxx types that are now in _typing.pyi , rather than npt.NDArray[np.integer], etc. I think it's better to use those types that we have in _typing.pyi so we can be consistent througout the stubs.
  2. pd.unique(someIndex) and Index.unique() are a bit of a mess, because the behavior changes from 2.3 to 3.0. See the release notes: https://pandas.pydata.org/docs/dev/whatsnew/v3.0.0.html#other . So what we need to do here is return the numpy types as is done in 2.3, and put in a comment to switch to the Index types when 3.0 is released.
  3. I don't think we should use npt.NDArray[np.double] in the stubs. We always use np.floating
  4. There are places where we can be more precise on what are the allowed numpy array types as arguments.

I didn't necessarily pick up everything related to the main issues, and some of my comments are related to the 3 issues above.

@cmp0xff cmp0xff marked this pull request as draft November 4, 2025 22:33
@cmp0xff cmp0xff marked this pull request as ready for review November 9, 2025 14:35
@cmp0xff cmp0xff requested a review from Dr-Irv November 9, 2025 14:35
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getting pretty close

Copy link
Contributor Author

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/pandas_nightly

@cmp0xff cmp0xff requested a review from Dr-Irv November 10, 2025 17:09
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @cmp0xff

@Dr-Irv Dr-Irv merged commit 71d53e8 into pandas-dev:main Nov 10, 2025
16 checks passed
@cmp0xff cmp0xff deleted the feature/reduce-ndarray branch November 10, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compat pandas objects compatability with Numpy or Python functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants