Skip to content
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

BUG: DecimalArray and JSONArray that are empty return incorrect results for isna() #21190

Merged
merged 1 commit into from
May 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
5 changes: 5 additions & 0 deletions pandas/tests/extension/base/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def test_isna(self, data_missing):
expected = pd.Series(expected)
self.assert_series_equal(result, expected)

# GH 21189
result = pd.Series(data_missing).drop([0, 1]).isna()
expected = pd.Series([], dtype=bool)
self.assert_series_equal(result, expected)

def test_dropna_series(self, data_missing):
ser = pd.Series(data_missing)
result = ser.dropna()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/extension/decimal/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def nbytes(self):
return 0

def isna(self):
return np.array([x.is_nan() for x in self._data])
return np.array([x.is_nan() for x in self._data], dtype=bool)

@property
def _na_value(self):
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/extension/json/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def nbytes(self):
return sys.getsizeof(self.data)

def isna(self):
return np.array([x == self.dtype.na_value for x in self.data])
return np.array([x == self.dtype.na_value for x in self.data],
dtype=bool)

def take(self, indexer, allow_fill=False, fill_value=None):
# re-implement here, since NumPy has trouble setting
Expand Down