Skip to content
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

__iter__() for Index & MultiIndex #1631

Closed
wants to merge 1 commit into from
Closed

Conversation

itholic
Copy link
Contributor

@itholic itholic commented Jul 6, 2020

This PR proposes __iter__() for Index & MultiIndex by using toLocalIterator like we did at DataFrame.iterrows and Series.iteritems.

>>> kidx = ks.Index([1, 2, 3])
>>> for value in kidx:
...     value
...
1
2
3

@HyukjinKwon
Copy link
Member

I think these were explicitly unsupported per #836

@itholic
Copy link
Contributor Author

itholic commented Jul 7, 2020

@HyukjinKwon , Thanks for the comment.

I just read the issue, but maybe I think the topic of that issue is more closer to "Koalas should returning ks.Series rather than np.array for pandas APIs that returning np.array" rather than "Koalas shouldn't support the __iter__ for ks.Series/ks.Index" ?

Because I think it is not that danger to just iterate the items in ks.Series or ks.Index one by one, unlike returning the whole item set in a ks.Series or ks.Index at once like pd.Series.unique().

What do you think about ?

@ueshin
Copy link
Collaborator

ueshin commented Jul 8, 2020

If we support it, users can unconsciously do list(kser) or [ do something for row in kser ] which cause OOM so easily.

@itholic
Copy link
Contributor Author

itholic commented Jul 8, 2020

@ueshin Thanks! I'd close this now :)

@itholic itholic closed this Jul 8, 2020
@itholic itholic deleted the i_iter branch July 25, 2020 04:08
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.

3 participants