Skip to content

Commit b941968

Browse files
committed
TST: add test for to_csv/from_csv inf and nan roundtrip
1 parent 9e0c3fe commit b941968

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/test_frame.py

+17
Original file line numberDiff line numberDiff line change
@@ -3382,6 +3382,23 @@ def test_to_csv_from_csv(self):
33823382

33833383
os.remove(path)
33843384

3385+
def test_to_csv_from_csv_w_infs(self):
3386+
path = '__tmp__'
3387+
3388+
# test roundtrip with inf, -inf, nan, as full columns and mix
3389+
self.frame['E'] = np.inf
3390+
self.frame['F'] = -np.inf
3391+
self.frame['G'] = np.nan
3392+
self.frame['H'] = self.frame.index.map(lambda x: [np.inf, np.nan][np.random.rand() < .5])
3393+
3394+
self.frame.to_csv(path)
3395+
recons = DataFrame.from_csv(path)
3396+
3397+
assert_frame_equal(self.frame, recons)
3398+
assert_frame_equal(np.isinf(self.frame), np.isinf(recons))
3399+
3400+
os.remove(path)
3401+
33853402
def test_to_csv_multiindex(self):
33863403
path = '__tmp__'
33873404

0 commit comments

Comments
 (0)