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

Implemented insert for Index & MultiIndex #1804

Merged
merged 4 commits into from
Oct 5, 2020

Conversation

itholic
Copy link
Contributor

@itholic itholic commented Sep 27, 2020

This PR proposes insert() for Index and MultiIndex

>>> kidx = ks.Index([1, 2, 3, 4, 5])
>>> kidx.insert(3, 100)
Int64Index([1, 2, 3, 100, 4, 5], dtype='int64')

>>> kidx = ks.Index([1, 2, 3, 4, 5])
>>> kidx.insert(-3, 100)
Int64Index([1, 2, 100, 3, 4, 5], dtype='int64')

>>> kmidx = ks.MultiIndex.from_tuples([("a", "x"), ("b", "y"), ("c", "z")])
>>> kmidx.insert(3, ("h", "j"))
MultiIndex([('a', 'x'),
            ('b', 'y'),
            ('c', 'z'),
            ('h', 'j')],
           )

>>> kmidx.insert(-2, ("h", "j"))
MultiIndex([('a', 'x'),
            ('h', 'j'),
            ('b', 'y'),
            ('c', 'z')],
                   )

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

Looks good otherwise.

@HyukjinKwon HyukjinKwon merged commit 7ae097f into databricks:master Oct 5, 2020
@itholic itholic deleted the i_insert branch October 6, 2020 00:16
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.

2 participants