Skip to content

BUG: fixed df.info() output missing new line #8114

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

Merged
merged 1 commit into from
Sep 12, 2014
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions doc/source/v0.15.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ API changes

- The Index set operations ``+`` and ``-`` were deprecated in order to provide these for numeric type operations on certain index types. ``+`` can be replace by ``.union()`` or ``|``, and ``-`` by ``.difference()``. Further the method name ``Index.diff()`` is deprecated and can be replaced by ``Index.difference()``

- ``DataFrame.info()`` now ends its output with a newline character (:issue:`8114`)

.. _whatsnew_0150.dt:

.dt accessor
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ def _non_verbose_repr():

counts = self.get_dtype_counts()
dtypes = ['%s(%d)' % k for k in sorted(compat.iteritems(counts))]
lines.append('dtypes: %s' % ', '.join(dtypes))
lines.append('dtypes: %s\n' % ', '.join(dtypes))
_put_lines(buf, lines)

def transpose(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def has_info_repr(df):
def has_non_verbose_info_repr(df):
has_info = has_info_repr(df)
r = repr(df)
nv = len(r.split('\n')) == 4 # 1. <class>, 2. Index, 3. Columns, 4. dtype
nv = len(r.split('\n')) == 5 # 1. <class>, 2. Index, 3. Columns, 4. dtype, 5. trailing newline
return has_info and nv

def has_horizontally_truncated_repr(df):
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6493,15 +6493,15 @@ def test_info_shows_column_dtypes(self):

def test_info_max_cols(self):
df = DataFrame(np.random.randn(10, 5))
for len_, verbose in [(4, None), (4, False), (9, True)]:
for len_, verbose in [(5, None), (5, False), (10, True)]:
# For verbose always ^ setting ^ summarize ^ full output
with option_context('max_info_columns', 4):
buf = StringIO()
df.info(buf=buf, verbose=verbose)
res = buf.getvalue()
self.assertEqual(len(res.split('\n')), len_)

for len_, verbose in [(9, None), (4, False), (9, True)]:
for len_, verbose in [(10, None), (5, False), (10, True)]:

# max_cols no exceeded
with option_context('max_info_columns', 5):
Expand All @@ -6510,7 +6510,7 @@ def test_info_max_cols(self):
res = buf.getvalue()
self.assertEqual(len(res.split('\n')), len_)

for len_, max_cols in [(9, 5), (4, 4)]:
for len_, max_cols in [(10, 5), (5, 4)]:
# setting truncates
with option_context('max_info_columns', 4):
buf = StringIO()
Expand Down