Skip to content

Commit 2561e1d

Browse files
committed
BUG: isnull works with float32, address GH #182
1 parent 11d2243 commit 2561e1d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pandas/src/tseries.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ cdef inline _isnan(object o):
227227
return o != o
228228

229229
cdef inline _checknull(object val):
230-
if isinstance(val, float):
230+
if isinstance(val, (float, np.floating)):
231231
return val != val or val == INF or val == NEGINF
232232
else:
233233
return val is None

pandas/tests/test_frame.py

+11
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,17 @@ def test_to_csv_multiindex(self):
15481548

15491549
os.remove(path)
15501550

1551+
def test_to_csv_float32_nanrep(self):
1552+
df = DataFrame(np.random.randn(1, 4).astype(np.float32))
1553+
df[1] = np.nan
1554+
1555+
pth = '__tmp__.csv'
1556+
df.to_csv(pth, nanRep=999)
1557+
1558+
lines = open(pth).readlines()
1559+
self.assert_(lines[1].split(',')[2] == '999')
1560+
os.remove(pth)
1561+
15511562
def test_info(self):
15521563
io = StringIO()
15531564
self.frame.info(buf=io)

0 commit comments

Comments
 (0)