Skip to content

Commit 2bdfcff

Browse files
committed
Merge pull request #7176 from shoyer/isnull-0d-object-array
BUG: fix isnull for 0d object arrays
2 parents 034c994 + bf46747 commit 2bdfcff

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ Bug Fixes
529529
- Fixed a bug with the `info` repr not honoring the `display.max_info_columns` setting (:issue:`6939`)
530530
- Bug ``PeriodIndex`` string slicing with out of bounds values (:issue:`5407`)
531531
- Fixed a memory error in the hashtable implementation/factorizer on resizing of large tables (:issue:`7157`)
532+
- Bug in ``isnull`` when applied to 0-dimensional object arrays (:issue:`7176`)
532533

533534
pandas 0.13.1
534535
-------------

pandas/core/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def _isnull_ndarraylike(obj):
213213
else:
214214
result = np.empty(shape, dtype=bool)
215215
vec = lib.isnullobj(values.ravel())
216-
result[:] = vec.reshape(shape)
216+
result[...] = vec.reshape(shape)
217217

218218
elif dtype in _DATELIKE_DTYPES:
219219
# this is the NaT pattern

pandas/tests/test_common.py

+12
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ def test_isnull_datetime():
135135
assert(mask[0])
136136
assert(not mask[1:].any())
137137

138+
139+
class TestIsNull(tm.TestCase):
140+
def test_0d_array(self):
141+
self.assertTrue(isnull(np.array(np.nan)))
142+
self.assertFalse(isnull(np.array(0.0)))
143+
self.assertFalse(isnull(np.array(0)))
144+
# test object dtype
145+
self.assertTrue(isnull(np.array(np.nan, dtype=object)))
146+
self.assertFalse(isnull(np.array(0.0, dtype=object)))
147+
self.assertFalse(isnull(np.array(0, dtype=object)))
148+
149+
138150
def test_downcast_conv():
139151
# test downcasting
140152

0 commit comments

Comments
 (0)