From 7beac1263f76b3fcaf481e0f9746b81c934360e3 Mon Sep 17 00:00:00 2001 From: immerrr Date: Mon, 5 May 2014 14:56:06 +0400 Subject: [PATCH] PERF: optimize Index.delete for dtype=object --- doc/source/release.rst | 5 +++-- doc/source/v0.14.0.txt | 6 ++++-- pandas/core/index.py | 5 ++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index 9bfc3609f5b6d..121cfb92b0eb2 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -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`): diff --git a/doc/source/v0.14.0.txt b/doc/source/v0.14.0.txt index c70e32fd18694..f19c1210b6a37 100644 --- a/doc/source/v0.14.0.txt +++ b/doc/source/v0.14.0.txt @@ -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 ` -- 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` diff --git a/pandas/core/index.py b/pandas/core/index.py index 96ecb66e86c67..ff6ee79bf24e4 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -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): """