Skip to content

Fix minor spacing issue #14196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions pandas/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,6 @@ def to_string(self):
self._chk_truncate()
strcols = self._to_str_columns()
text = self.adj.adjoin(1, *strcols)
if not self.index:
text = text.replace('\n ', '\n').strip()
self.buf.writelines(text)

if self.should_show_dimensions:
Expand Down Expand Up @@ -735,7 +733,7 @@ def space_format(x, y):
fmt_columns = columns.format()
dtypes = self.frame.dtypes
need_leadsp = dict(zip(fmt_columns, map(is_numeric_dtype, dtypes)))
str_columns = [[' ' + x if not self._get_formatter(i) and
str_columns = [[x if not self._get_formatter(i) and
need_leadsp[x] else x]
for i, (col, x) in enumerate(zip(columns,
fmt_columns))]
Expand Down Expand Up @@ -1988,11 +1986,11 @@ def _format(x):
fmt_values = []
for i, v in enumerate(vals):
if not is_float_type[i] and leading_space:
fmt_values.append(' %s' % _format(v))
fmt_values.append('%s' % _format(v))
elif is_float_type[i]:
fmt_values.append(float_format(v))
else:
fmt_values.append(' %s' % _format(v))
fmt_values.append('%s' % _format(v))

return fmt_values

Expand Down Expand Up @@ -2134,7 +2132,7 @@ def _format_strings(self):

class IntArrayFormatter(GenericArrayFormatter):
def _format_strings(self):
formatter = self.formatter or (lambda x: '% d' % x)
formatter = self.formatter or (lambda x: '%d' % x)
fmt_values = [formatter(x) for x in self.values]
return fmt_values

Expand Down