Skip to content

Commit 3b355e5

Browse files
committed
Added tests for to_string and to_latex
1 parent a727a19 commit 3b355e5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/formats/test_format.py

+11
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,17 @@ def test_to_string_no_header(self):
11251125

11261126
self.assertEqual(df_s, expected)
11271127

1128+
def test_to_latex_specified_header(self):
1129+
df = DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
1130+
1131+
df_s = df.to_string(header=['X', 'Y'])
1132+
expected = ' X Y\n0 1 4\n1 2 5\n2 3 6'
1133+
1134+
self.assertEqual(df_s, expected)
1135+
1136+
with tm.assertRaises(ValueError):
1137+
df.to_string(header=['X'])
1138+
11281139
def test_to_string_no_index(self):
11291140
df = DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
11301141

0 commit comments

Comments
 (0)