Skip to content

Commit f67e30f

Browse files
committed
feat: only display row count when series is large than the number can be displayed in one page
1 parent 9dff0f4 commit f67e30f

File tree

2 files changed

+186
-187
lines changed

2 files changed

+186
-187
lines changed

bigframes/series.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -607,26 +607,25 @@ def _create_text_representation(
607607
"""Create a text representation of the Series."""
608608
opts = bigframes.options.display
609609
with display_options.pandas_repr(opts):
610-
import pandas.io.formats
611-
612-
# safe to mutate this, this dict is owned by this code, and does not affect global config
613-
to_string_kwargs = (
614-
pandas.io.formats.format.get_series_repr_params() # type: ignore
615-
)
616-
if len(self._block.index_columns) == 0:
617-
to_string_kwargs.update({"index": False})
618610
# Get the first column since Series DataFrame has only one column
619611
pd_series = pandas_df.iloc[:, 0]
620-
repr_string = pd_series.to_string(**to_string_kwargs)
612+
if len(self._block.index_columns) == 0:
613+
repr_string = pd_series.to_string(
614+
length=False, index=False, name=True, dtype=True
615+
)
616+
else:
617+
repr_string = pd_series.to_string(length=False, name=True, dtype=True)
621618

622-
lines = repr_string.split("\n")
619+
is_truncated = total_rows is not None and total_rows > len(pd_series)
623620

624-
if total_rows is not None and total_rows > len(pd_series):
621+
if is_truncated:
622+
lines = repr_string.split("\n")
625623
lines.append("...")
626-
627-
lines.append("")
628-
lines.append(f"[{total_rows} rows]")
629-
return "\n".join(lines)
624+
lines.append("")
625+
lines.append(f"[{total_rows} rows]")
626+
return "\n".join(lines)
627+
else:
628+
return repr_string
630629

631630
def _repr_mimebundle_(self, include=None, exclude=None):
632631
"""

0 commit comments

Comments
 (0)