Skip to content

Commit 6398950

Browse files
committed
appended newline to DataFrame.info() output
1 parent d5c9a22 commit 6398950

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

doc/source/v0.15.0.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ API changes
349349

350350
- 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()``
351351

352+
- ``DataFrame.info()`` now ends its output with a newline character (:issue:`8114`)
353+
352354
.. _whatsnew_0150.dt:
353355

354356
.dt accessor

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ def _non_verbose_repr():
14731473

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

14791479
def transpose(self):

pandas/tests/test_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def has_info_repr(df):
4343
def has_non_verbose_info_repr(df):
4444
has_info = has_info_repr(df)
4545
r = repr(df)
46-
nv = len(r.split('\n')) == 4 # 1. <class>, 2. Index, 3. Columns, 4. dtype
46+
nv = len(r.split('\n')) == 5 # 1. <class>, 2. Index, 3. Columns, 4. dtype, 5. trailing newline
4747
return has_info and nv
4848

4949
def has_horizontally_truncated_repr(df):

pandas/tests/test_frame.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6493,15 +6493,15 @@ def test_info_shows_column_dtypes(self):
64936493

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

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

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

6513-
for len_, max_cols in [(9, 5), (4, 4)]:
6513+
for len_, max_cols in [(10, 5), (5, 4)]:
65146514
# setting truncates
65156515
with option_context('max_info_columns', 4):
65166516
buf = StringIO()

0 commit comments

Comments
 (0)