Skip to content

Commit c539f24

Browse files
author
gshiba
committed
Match style to other tests in this module
1 parent 5b4a89c commit c539f24

File tree

1 file changed

+14
-33
lines changed

1 file changed

+14
-33
lines changed

pandas/tests/io/formats/test_format.py

+14-33
Original file line numberDiff line numberDiff line change
@@ -1270,39 +1270,20 @@ def test_to_string_specified_header(self):
12701270

12711271
def test_to_string_no_index(self):
12721272

1273-
dfs = [
1274-
1275-
# ints
1276-
DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]}),
1277-
DataFrame({'x': [11, 22, 33], 'y': [4, 5, 6]}),
1278-
DataFrame({'x': [11, 22, -33], 'y': [4, 5, 6]}),
1279-
DataFrame({'x': [11, 22, -33], 'y': [4, 5, -6]}),
1280-
DataFrame({'x': [11, 22, -33], 'y': [44, 55, -66]}),
1281-
1282-
# floats
1283-
DataFrame({'x': [0.1, 0.2, -0.3], 'y': [4, 5, 6]}),
1284-
DataFrame({'x': [0.1, 0.2, -0.3], 'y': [0.4, 0.5, 0.6]}),
1285-
DataFrame({'x': [0.1, 0.2, -0.3], 'y': [0.4, 0.5, -0.6]}),
1286-
]
1287-
1288-
exs = [
1289-
1290-
# ints
1291-
" x y\n 1 4\n 2 5\n 3 6",
1292-
" x y\n 11 4\n 22 5\n 33 6",
1293-
" x y\n 11 4\n 22 5\n-33 6",
1294-
" x y\n 11 4\n 22 5\n-33 -6",
1295-
" x y\n 11 44\n 22 55\n-33 -66",
1296-
1297-
# floats
1298-
" x y\n 0.1 4\n 0.2 5\n-0.3 6",
1299-
" x y\n 0.1 0.4\n 0.2 0.5\n-0.3 0.6",
1300-
" x y\n 0.1 0.4\n 0.2 0.5\n-0.3 -0.6",
1301-
]
1302-
1303-
for df, expected in zip(dfs, exs):
1304-
df_s = df.to_string(index=False)
1305-
assert df_s == expected
1273+
df = DataFrame({'x': [11, 22], 'y': [33, -44], 'z': ['AAA', ' ']})
1274+
1275+
df_s = df.to_string(index=False)
1276+
# Leading space is expected for positive numbers.
1277+
expected = (" x y z\n
1278+
" 11 33 AAA\n"
1279+
" 22 -44 ")
1280+
assert df_s == expected
1281+
1282+
df_s = df[['y', 'x', 'z']].to_string(index=False)
1283+
expected = (" y x z\n"
1284+
" 33 11 AAA\n"
1285+
"-44 22 ")
1286+
assert df_s == expected
13061287

13071288
def test_to_string_line_width_no_index(self):
13081289
df = DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})

0 commit comments

Comments
 (0)