We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fffd92f commit f48a954Copy full SHA for f48a954
pandas/core/frame.py
@@ -626,7 +626,18 @@ def _repr_fits_horizontal_(self):
626
return False
627
628
buf = StringIO()
629
- self.to_string(buf=buf)
+
630
+ # only care about the stuff we'll actually print out
631
+ # and to_string on entire frame may be expensive
632
+ d = self
633
+ max_rows = get_option("display.max_rows")
634
+ if not (height is None and max_rows is None):
635
+ # min of two, where one may be None
636
+ height = height or max_rows +1
637
+ max_rows = max_rows or height +1
638
+ d=d.iloc[:min(max_rows, height)]
639
640
+ d.to_string(buf=buf)
641
value = buf.getvalue()
642
repr_width = max([len(l) for l in value.split('\n')])
643
return repr_width <= width
0 commit comments