Skip to content

Commit 17d5d99

Browse files
authored
TST: added test for to_string when max_rows is zero (GH35394) (#43300)
1 parent 26c9185 commit 17d5d99

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pandas/tests/io/formats/test_to_string.py

+23
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,26 @@ def test_to_string_na_rep_and_float_format(na_rep):
315315
1 A {na_rep}"""
316316
)
317317
assert result == expected
318+
319+
320+
@pytest.mark.parametrize(
321+
"data,expected",
322+
[
323+
(
324+
{"col1": [1, 2], "col2": [3, 4]},
325+
" col1 col2\n0 1 3\n1 2 4",
326+
),
327+
(
328+
{"col1": ["Abc", 0.756], "col2": [np.nan, 4.5435]},
329+
" col1 col2\n0 Abc NaN\n1 0.756 4.5435",
330+
),
331+
(
332+
{"col1": [np.nan, "a"], "col2": [0.009, 3.543], "col3": ["Abc", 23]},
333+
" col1 col2 col3\n0 NaN 0.009 Abc\n1 a 3.543 23",
334+
),
335+
],
336+
)
337+
def test_to_string_max_rows_zero(data, expected):
338+
# GH35394
339+
result = DataFrame(data=data).to_string(max_rows=0)
340+
assert result == expected

0 commit comments

Comments
 (0)