Skip to content

PERF: optimize Index.delete for dtype=object #7040

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

Merged
merged 1 commit into from
May 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ API Changes

- ``concat`` will now concatenate mixed Series and DataFrames using the Series name
or numbering columns as needed (:issue:`2385`)
- Slicing and advanced/boolean indexing operations on ``Index`` classes will no
longer change type of the resulting index (:issue:`6440`).
- Slicing and advanced/boolean indexing operations on ``Index`` classes as well
as :meth:`Index.delete` and :meth:`Index.drop` methods will no longer change type of the
resulting index (:issue:`6440`, :issue:`7040`)
- ``set_index`` no longer converts MultiIndexes to an Index of tuples (:issue:`6459`).
- Slicing with negative start, stop & step values handles corner cases better (:issue:`6531`):

Expand Down
6 changes: 4 additions & 2 deletions doc/source/v0.14.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,15 @@ API changes

- ``concat`` will now concatenate mixed Series and DataFrames using the Series name
or numbering columns as needed (:issue:`2385`). See :ref:`the docs <merging.mixed_ndims>`
- Slicing and advanced/boolean indexing operations on ``Index`` classes will no
longer change type of the resulting index (:issue:`6440`)
- Slicing and advanced/boolean indexing operations on ``Index`` classes as well
as :meth:`Index.delete` and :meth:`Index.drop` methods will no longer change type of the
resulting index (:issue:`6440`, :issue:`7040`)

.. ipython:: python

i = pd.Index([1, 2, 3, 'a' , 'b', 'c'])
i[[0,1,2]]
i.drop(['a', 'b', 'c'])

Previously, the above operation would return ``Int64Index``. If you'd like
to do this manually, use :meth:`Index.astype`
Expand Down
5 changes: 2 additions & 3 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1760,14 +1760,13 @@ def slice_locs(self, start=None, end=None):

def delete(self, loc):
"""
Make new Index with passed location deleted
Make new Index with passed location(-s) deleted

Returns
-------
new_index : Index
"""
arr = np.delete(self.values, loc)
return Index(arr)
return np.delete(self, loc)

def insert(self, loc, item):
"""
Expand Down