Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9764ea6

Browse files
committedApr 12, 2013
Merge pull request #3332 from jreback/period_perf2
PERF/CLN: infer Period in infer_dtype, later index inference is faster
2 parents 57d9fad + 97d37d9 commit 9764ea6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
 

‎pandas/core/index.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ def __new__(cls, data, dtype=None, copy=False, name=None):
127127
from pandas.tseries.index import DatetimeIndex
128128
return DatetimeIndex(subarr, copy=copy, name=name)
129129

130-
if lib.is_period_array(subarr):
131-
return PeriodIndex(subarr, name=name)
130+
elif inferred == 'period':
131+
return PeriodIndex(subarr, name=name)
132132

133133
subarr = subarr.view(cls)
134134
subarr.name = name

‎pandas/src/inference.pyx

+8
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ def infer_dtype(object _values):
9797
if is_timedelta_or_timedelta64_array(values):
9898
return 'timedelta'
9999

100+
elif is_period(val):
101+
if is_period_array(values):
102+
return 'period'
103+
100104
for i in range(n):
101105
val = util.get_value_1d(values, i)
102106
if util.is_integer_object(val):
@@ -321,6 +325,10 @@ def is_time_array(ndarray[object] values):
321325
return False
322326
return True
323327

328+
def is_period(object o):
329+
from pandas import Period
330+
return isinstance(o,Period)
331+
324332
def is_period_array(ndarray[object] values):
325333
cdef int i, n = len(values)
326334
from pandas import Period

0 commit comments

Comments
 (0)
Please sign in to comment.