Skip to content
Merged
2 changes: 1 addition & 1 deletion pandas/io/formats/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ def headers(self) -> Sequence[str]:

def _gen_rows_without_counts(self) -> Iterator[Sequence[str]]:
"""Iterator with string representation of body data without counts."""
yield from self._gen_dtypes()
yield from ([dtype] for dtype in self._gen_dtypes())

def _gen_rows_with_counts(self) -> Iterator[Sequence[str]]:
"""Iterator with string representation of body data with counts."""
Expand Down
20 changes: 20 additions & 0 deletions pandas/tests/series/methods/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,23 @@ def test_info_memory_usage_bug_on_multiindex():
# high upper bound
diff = unstacked.memory_usage(deep=True).sum() - s.memory_usage(deep=True)
assert diff < 2000


def test_info_show_counts_false():
s = Series([1])
buf = StringIO()
s.info(buf=buf, show_counts=False)
result = buf.getvalue()
memory_bytes = float(s.memory_usage())
expected = textwrap.dedent(
f"""\
<class 'pandas.Series'>
RangeIndex: 1 entries, 0 to 0
Series name: None
Dtype
-----
int64
dtypes: int64(1)
memory usage: {memory_bytes} bytes"""
)
assert result.strip() == expected.strip()
Loading