Skip to content

PERF: pd.Index.is_all_dates doesn't require full-scan inference #6341

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
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
1 change: 1 addition & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Improvements to existing features
the func (:issue:`6289`)
- ``plot(legend='reverse')`` will now reverse the order of legend labels for most plot kinds.
(:issue:`6014`)
- improve performance of slice indexing on Series with string keys (:issue:`6341`)

.. _release.bug_fixes-0.14.0:

Expand Down
2 changes: 1 addition & 1 deletion doc/source/v0.14.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Enhancements
and parse accordingly. (:issue:`6223`)
- ``plot(legend='reverse')`` will now reverse the order of legend labels for
most plot kinds. (:issue:`6014`)

- improve performance of slice indexing on Series with string keys (:issue:`6341`)

Performance
~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pandas.lib as lib
import pandas.algos as _algos
import pandas.index as _index
from pandas.lib import Timestamp
from pandas.lib import Timestamp, is_datetime_array
from pandas.core.base import FrozenList, FrozenNDArray

from pandas.util.decorators import cache_readonly, deprecate
Expand Down Expand Up @@ -577,7 +577,7 @@ def is_type_compatible(self, typ):

@cache_readonly
def is_all_dates(self):
return self.inferred_type == 'datetime'
return is_datetime_array(self.values)

def __iter__(self):
return iter(self.values)
Expand Down
11 changes: 10 additions & 1 deletion vb_suite/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

#----------------------------------------------------------------------
# Series.__getitem__, get_value
# Series.__getitem__, get_value, __getitem__(slice)

setup = common_setup + """
tm.N = 1000
Expand All @@ -29,6 +29,15 @@
name='series_get_value',
start_date=datetime(2011, 11, 12))


setup = common_setup + """
index = tm.makeStringIndex(1000000)
s = Series(np.random.rand(1000000), index=index)
"""
series_getitem_slice = Benchmark("s[:800000]", setup,
name="series_getitem_slice")


#----------------------------------------------------------------------
# DataFrame __getitem__

Expand Down