Skip to content

[SPARK-52592][PS] Prevent error when creating ps.Series from ps.Series #51300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

petern48
Copy link

What changes were proposed in this pull request?

I fixed the constructor to explicitly handle Series input similar to how it handles DataFrame input. It previously would fall to the else case that inputs it into a regular pandas Series constructor, leading to the error.

Why are the changes needed?

Previously, this code

obj = ps.Series([x for x in range(3)])
obj = ps.Series(obj)

would error:

...
pyspark.pandas.exceptions.PandasNotImplementedError: The method `pd.Series.__iter__()` is not implemented. If you want to collect your data as an NumPy array, use 'to_numpy()' instead.

Does this PR introduce any user-facing change?

Yes, previously, when you try to pass a ps.Series object into the ps.Series.__init__(), you can an error. Now, it will work successfully similar to how traditional pandas Series works.

How was this patch tested?

Yes, I added a test.

Was this patch authored or co-authored using generative AI tooling?

No

@petern48 petern48 force-pushed the series_from_series branch from fa8bba2 to 75b845e Compare June 27, 2025 05:37
@petern48 petern48 changed the title [WIP][SPARK-52592][PS] Prevent error when creating ps.Series from ps.Series [SPARK-52592][PS] Prevent error when creating ps.Series from ps.Series Jun 27, 2025
@petern48 petern48 marked this pull request as ready for review June 27, 2025 15:57
@petern48
Copy link
Author

Once this is merged, I'd like to backport this as far back as 3.4.0 if possible, or at least back to 3.5.0

Copy link
Contributor

@allisonwang-db allisonwang-db left a comment

Choose a reason for hiding this comment

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

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

Successfully merging this pull request may close these issues.

2 participants