Skip to content

Commit 8bf0428

Browse files
committed
[fragile] Only remove whitespace for subset of dtypes
1 parent 4b0e4c8 commit 8bf0428

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pandas/formats/format.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,10 @@ def to_string(self):
604604
self._chk_truncate()
605605
strcols = self._to_str_columns()
606606
text = self.adj.adjoin(1, *strcols)
607-
if not self.index:
607+
608+
first_column_dtype = (None if len(frame.columns) == 0
609+
else frame.dtypes[frame.columns[0]])
610+
if not self.index and first_column_dtype.kind != 'O':
608611
# Remove a single space from the beginning of each line
609612
# and remove any trailing spaces
610613
if len(text) > 0 and text[0] == ' ':

0 commit comments

Comments
 (0)