diff --git a/pandas/core/index.py b/pandas/core/index.py index 57222d6a04c2f..43cb7734a1cc5 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -127,8 +127,8 @@ def __new__(cls, data, dtype=None, copy=False, name=None): from pandas.tseries.index import DatetimeIndex return DatetimeIndex(subarr, copy=copy, name=name) - if lib.is_period_array(subarr): - return PeriodIndex(subarr, name=name) + elif inferred == 'period': + return PeriodIndex(subarr, name=name) subarr = subarr.view(cls) subarr.name = name diff --git a/pandas/src/inference.pyx b/pandas/src/inference.pyx index 3ecf513cc3212..7d13aa8ce6765 100644 --- a/pandas/src/inference.pyx +++ b/pandas/src/inference.pyx @@ -97,6 +97,10 @@ def infer_dtype(object _values): if is_timedelta_or_timedelta64_array(values): return 'timedelta' + elif is_period(val): + if is_period_array(values): + return 'period' + for i in range(n): val = util.get_value_1d(values, i) if util.is_integer_object(val): @@ -321,6 +325,10 @@ def is_time_array(ndarray[object] values): return False return True +def is_period(object o): + from pandas import Period + return isinstance(o,Period) + def is_period_array(ndarray[object] values): cdef int i, n = len(values) from pandas import Period