Closed
Description
With 0.17.1, justification is handled correctly:
In [3]: df = pd.DataFrame(np.random.randn(3, 3), columns=['one', 'two', 'three'])
In [4]: print df.to_string(index=False)
one two three
0.096065 -0.529437 -2.058535
0.588013 0.221911 -2.400129
0.848234 -0.093931 1.221708
But in 0.18.0, it's broken:
In [4]: print df.to_string(index=False)
one two three
1.164170 -0.027236 -0.114962
-1.405931 0.019395 0.743320
0.598321 0.655802 -1.061834
This is caused by PR #11942. The issue it was meant to fix (#11833) is actually caused by using the format string "% d" for formatting integers, which produces a leading space if the integer is positive (where the minus sign would go for a negative integer). My preferred solution would be to change the formatter to "%d" (and to revert #11942), which would have the added bonus of eliminating double spaces between some columns (see the first to_string
output in #11833, for example). A bunch of formatting tests would have to be adjusted, though. Is there anyone who prefers the extra space?