Skip to content

Commit 6636ad5

Browse files
committed
whatsnew note / fixes xref #4125
1 parent 879f5e9 commit 6636ad5

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

doc/source/whatsnew/v0.17.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ Bug Fixes
10231023
- Bug in ``read_stata`` when reading a file with a different order set in ``columns`` (:issue:`10757`)
10241024
- Bug in ``Categorical`` may not representing properly when category contains ``tz`` or ``Period`` (:issue:`10713`)
10251025
- Bug in ``Categorical.__iter__`` may not returning correct ``datetime`` and ``Period`` (:issue:`10713`)
1026-
1026+
- Bug in indexing with a ``PeriodIndex`` on an object with a ``PeriodIndex`` (:issue:`4125`)
10271027
- Bug in ``read_csv`` with ``engine='c'``: EOF preceded by a comment, blank line, etc. was not handled correctly (:issue:`10728`, :issue:`10548`)
10281028

10291029
- Reading "famafrench" data via ``DataReader`` results in HTTP 404 error because of the website url is changed (:issue:`10591`).

pandas/core/index.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
deprecate, deprecate_kwarg)
2020
import pandas.core.common as com
2121
from pandas.core.common import (isnull, array_equivalent, is_dtype_equal, is_object_dtype,
22-
is_datetimetz,
22+
is_datetimetz, ABCSeries, ABCCategorical, ABCPeriodIndex,
2323
_values_from_object, is_float, is_integer, is_iterator, is_categorical_dtype,
24-
ABCSeries, ABCCategorical, _ensure_object, _ensure_int64, is_bool_indexer,
24+
_ensure_object, _ensure_int64, is_bool_indexer,
2525
is_list_like, is_bool_dtype, is_null_slice, is_integer_dtype)
2626
from pandas.core.config import get_option
2727
from pandas.io.common import PerformanceWarning
@@ -976,8 +976,8 @@ def _convert_list_indexer(self, keyarr, kind=None):
976976
and we have a mixed index (e.g. number/labels). figure out
977977
the indexer. return None if we can't help
978978
"""
979-
if (kind is None or kind in ['iloc', 'ix']) and (
980-
is_integer_dtype(keyarr) and not self.is_floating() and not com.is_period_arraylike(keyarr)):
979+
if kind in [None, 'iloc', 'ix'] and is_integer_dtype(keyarr) \
980+
and not self.is_floating() and not isinstance(keyarr, ABCPeriodIndex):
981981

982982
if self.inferred_type != 'integer':
983983
keyarr = np.where(keyarr < 0,

pandas/tests/test_index.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3261,7 +3261,9 @@ def test_period_index_indexer(self):
32613261
df = pd.DataFrame(pd.np.random.randn(24,10), index=idx)
32623262
self.assert_frame_equal(df, df.ix[idx])
32633263
self.assert_frame_equal(df, df.ix[list(idx)])
3264-
3264+
self.assert_frame_equal(df, df.loc[list(idx)])
3265+
self.assert_frame_equal(df.iloc[0:5], df.loc[idx[0:5]])
3266+
self.assert_frame_equal(df, df.loc[list(idx)])
32653267

32663268
class TestTimedeltaIndex(DatetimeLike, tm.TestCase):
32673269
_holder = TimedeltaIndex

0 commit comments

Comments
 (0)