Skip to content

Commit

Permalink
COMPAT: fixup decimal extension for indexing compat (#19882)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback authored Feb 24, 2018
1 parent feedf66 commit e97be6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pandas/tests/extension/base/getitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def test_iloc_series(self, data):
self.assert_series_equal(result, expected)

def test_iloc_frame(self, data):
df = pd.DataFrame({"A": data, 'B': np.arange(len(data))})
df = pd.DataFrame({"A": data, 'B':
np.arange(len(data), dtype='int64')})
expected = pd.DataFrame({"A": data[:4]})

# slice -> frame
Expand Down Expand Up @@ -49,7 +50,8 @@ def test_loc_series(self, data):
self.assert_series_equal(result, expected)

def test_loc_frame(self, data):
df = pd.DataFrame({"A": data, 'B': np.arange(len(data))})
df = pd.DataFrame({"A": data,
'B': np.arange(len(data), dtype='int64')})
expected = pd.DataFrame({"A": data[:4]})

# slice -> frame
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/extension/decimal/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pandas as pd
from pandas.core.arrays import ExtensionArray
from pandas.core.dtypes.base import ExtensionDtype
from pandas.core.dtypes.common import _ensure_platform_int


class DecimalDtype(ExtensionDtype):
Expand Down Expand Up @@ -68,6 +69,7 @@ def isna(self):
def take(self, indexer, allow_fill=True, fill_value=None):
mask = indexer == -1

indexer = _ensure_platform_int(indexer)
out = self.values.take(indexer)
out[mask] = self._na_value

Expand Down

0 comments on commit e97be6f

Please sign in to comment.