Skip to content

GH1727 Narrow Series.to_numpy return types based on the dtype argument#1736

Open
loicdiridollou wants to merge 7 commits into
pandas-dev:mainfrom
loicdiridollou:gh1727_to_numpy
Open

GH1727 Narrow Series.to_numpy return types based on the dtype argument#1736
loicdiridollou wants to merge 7 commits into
pandas-dev:mainfrom
loicdiridollou:gh1727_to_numpy

Conversation

@loicdiridollou
Copy link
Copy Markdown
Member

@loicdiridollou loicdiridollou commented May 8, 2026

Added the following deprecation:

  • Enforced deprecation of axis=None acting the same as axis=0 in the DataFrame reductions sum, prod, std, var, and sem, passing axis=None will now reduce over both axes; this is particularly the case when doing e.g. numpy.sum(df) (Support axis=None in all reductions pandas#21597)

@loicdiridollou loicdiridollou marked this pull request as draft May 8, 2026 17:41
**kwargs: Any,
) -> np_1darray_object: ...
@overload
def to_numpy(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not totally sure if this one is really in the spirit of the stubs since we have all the other np_1darray_xxx but thought it was worth offering since once we do the to_numpy it goes into the numpy ground.

@loicdiridollou loicdiridollou marked this pull request as ready for review May 8, 2026 23:42
@loicdiridollou loicdiridollou requested a review from cmp0xff May 8, 2026 23:51
Comment thread tests/series/test_series.py Outdated
Comment thread tests/series/test_series.py Outdated
Comment thread pandas-stubs/core/series.pyi
Comment thread tests/series/test_series.py
@loicdiridollou loicdiridollou requested a review from cmp0xff May 10, 2026 18:30
Comment thread tests/series/test_series.py Outdated
@loicdiridollou loicdiridollou requested a review from cmp0xff May 11, 2026 20:44
Copy link
Copy Markdown
Contributor

@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.

In my example in #1727 (comment), np.dtypes.Float64DType() and np.dtypes.Float64DType etc should also work. Currently they are missing from the tests.

@loicdiridollou
Copy link
Copy Markdown
Member Author

Added a lot more tests to fit, let me know what you think!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing specialization for to_numpy for Series[float] and Series[int]

2 participants