Skip to content

COMPAT: fixup decimal extension for indexing compat #19882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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