Skip to content

Conversation

@loicdiridollou
Copy link
Member

Should address the most general case for each type, happy to improve with the dtype parameter, from experience this is not used a lot but let me know, good to restrict some of those types.

@loicdiridollou
Copy link
Member Author

Seems like I should be able to restrict some of the types.
Otherwise I see the issue with Windows, will play around with it (may need to push a few times since I don't have a windows box at home).

Copy link
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.

One comment to fix the warning on Windows. Others are just ideas.

copy: bool = False,
na_value: Scalar = ...,
**kwargs: Any,
) -> np_1darray[np.integer]: ...
Copy link
Contributor

Choose a reason for hiding this comment

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

In #1462 we are introducing np_1darray_anyint etc., which will be enforced in the stubs in the future. But I think this #1476 will be merged before #1462, and I can make the necessary changes in #1462.

Copy link
Member Author

Choose a reason for hiding this comment

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

Prob let's make a change after, or hold on this one and I will make the changes once you merge the other ones, up to you, fine with both options!

],
dtype="datetime64[ns]",
)
s7 = pd.Series(pd.PeriodIndex(dates, freq="M"))
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a conversion function

Suggested change
s7 = pd.Series(pd.PeriodIndex(dates, freq="M"))
s7 = pd.PeriodIndex(dates, freq="M").to_series()


def test_to_numpy() -> None:
"""Test Series.to_numpy for different types."""
s1 = pd.Series(["a", "b", "c"], dtype=str)
Copy link
Contributor

Choose a reason for hiding this comment

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

s1 does not give a hint to the intention of the test. Maybe s_str can help more. Just an idea 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

I have remained all the variables, clearer indeed.

Comment on lines 2046 to 2050
s9 = (
pd.Series(pd.period_range(start="2017-01-01", end="2017-02-01", freq="1D"))
.diff()
.iloc[1:]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe

Suggested change
s9 = (
pd.Series(pd.period_range(start="2017-01-01", end="2017-02-01", freq="1D"))
.diff()
.iloc[1:]
)
s9 = pd.Series([Day(1)]).to_numpy()

)

s11 = pd.Series(
[datetime.datetime.now().date(), datetime.datetime.now().date()]
Copy link
Contributor

Choose a reason for hiding this comment

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

datetime.now will eventually be caught by DTZ005 in the future. But it is fine for now.

@cmp0xff cmp0xff added Compat pandas objects compatability with Numpy or Python functions Series Series data structure labels Nov 10, 2025
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 Series Series data structure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

to_numpy does not reflect S1 in pd.Series[S1]

2 participants