Skip to content

Commit

Permalink
BUG: DecimalArray and JSONArray that are empty return incorrect resul…
Browse files Browse the repository at this point in the history
…ts for isna() (pandas-dev#21190)

(cherry picked from commit 6f1f975)
  • Loading branch information
Dr-Irv authored and jorisvandenbossche committed Jun 8, 2018
1 parent 77aa0c4 commit 761994c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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

0 comments on commit 761994c

Please sign in to comment.