Skip to content

Indexing by a list of Periods fails to return a series #7710

Closed
@numpand

Description

@numpand
In [1]: import pandas as pd

In [2]: pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.7.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 30 Stepping 5, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.14.0
nose: 1.3.3
Cython: 0.20.2
numpy: 1.8.1
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 2.1.0
sphinx: 1.2.2
patsy: 0.2.1
scikits.timeseries: None
dateutil: 1.5
pytz: 2014.4
bottleneck: None
tables: 3.1.1
numexpr: 2.3.1
matplotlib: 1.3.1
openpyxl: 1.8.5
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.5.5
lxml: 3.3.5
bs4: 4.3.1
html5lib: 0.999
bq: None
apiclient: None
rpy2: 2.3.9
sqlalchemy: 0.9.4
pymysql: None
psycopg2: 2.5.3 (dt dec pq3 ext)

In [3]: s = pd.TimeSeries(1, [pd.Period('2002-01-01',freq='D')])

In [4]: s[[0]]
Out[4]:
2002-01-01    1
Freq: D, dtype: int64

In [5]: s[[pd.Period('2002-01-01',freq='D')]]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-0e636383b52c> in <module>()
----> 1 s[[pd.Period('2002-01-01',freq='D')]]

C:\Python27\lib\site-packages\pandas\core\series.pyc in __getitem__(self, key)
    517             key = _check_bool_indexer(self.index, key)
    518
--> 519         return self._get_with(key)
    520
    521     def _get_with(self, key):

C:\Python27\lib\site-packages\pandas\core\series.pyc in _get_with(self, key)
    555                     # handle the dup indexing case (GH 4246)
    556                     if isinstance(key, (list, tuple)):
--> 557                         return self.ix[key]
    558
    559                     return self.reindex(key)

C:\Python27\lib\site-packages\pandas\core\indexing.pyc in __getitem__(self, key)
     68             return self._getitem_tuple(key)
     69         else:
---> 70             return self._getitem_axis(key, axis=0)
     71
     72     def _get_label(self, label, axis=0):

C:\Python27\lib\site-packages\pandas\core\indexing.pyc in _getitem_axis(self, key, axis, validate_iterable)
    849                 raise ValueError('Cannot index with multidimensional key')
    850
--> 851             return self._getitem_iterable(key, axis=axis)
    852         else:
    853             if com.is_integer(key):

C:\Python27\lib\site-packages\pandas\core\indexing.pyc in _getitem_iterable(self, key, axis)
    905             # existing labels are unique and indexer is unique
    906             if labels.is_unique and keyarr_is_unique:
--> 907                 return _reindex(keyarr, level=level)
    908
    909             else:

C:\Python27\lib\site-packages\pandas\core\indexing.pyc in _reindex(keys, level)
    875                 if axis != 0:
    876                     raise AssertionError('axis must be 0')
--> 877                 return self.obj.reindex(keys, level=level)
    878
    879         if com._is_bool_indexer(key):

C:\Python27\lib\site-packages\pandas\core\series.pyc in reindex(self, index, **kwargs)
   2026     @Appender(generic._shared_docs['reindex'] % _shared_doc_kwargs)
   2027     def reindex(self, index=None, **kwargs):
-> 2028         return super(Series, self).reindex(index=index, **kwargs)
   2029
   2030     def reindex_axis(self, labels, axis=0, **kwargs):

C:\Python27\lib\site-packages\pandas\core\generic.pyc in reindex(self, *args, **kwargs)
   1608         # if indicated must have index names equal here as well as values
   1609         if all([self._get_axis(axis).identical(ax)
-> 1610                 for axis, ax in axes.items() if ax is not None]):
   1611             if copy:
   1612                 return self.copy()

C:\Python27\lib\site-packages\pandas\core\index.pyc in identical(self, other)
    849         also equal
    850         """
--> 851         return (self.equals(other) and
    852                 all((getattr(self, c, None) == getattr(other, c, None)
    853                      for c in self._comparables)) and

C:\Python27\lib\site-packages\pandas\tseries\period.pyc in equals(self, other)
    822             return True
    823
--> 824         return np.array_equal(self.asi8, other.asi8)
    825
    826     def tolist(self):

AttributeError: 'numpy.ndarray' object has no attribute 'asi8'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselvesPeriodPeriod data typeTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions