@@ -602,14 +602,20 @@ def __nonzero__(self):
602
602
def _repr_fits_vertical_ (self ):
603
603
"""
604
604
Check if full repr fits in vertical boundaries imposed by the display
605
- options height and max_rows. In case off non-interactive session,
605
+ options height and max_rows. In case of non-interactive session,
606
606
no boundaries apply.
607
607
"""
608
608
width , height = fmt .get_console_size ()
609
+ max_rows = get_option ("display.max_rows" )
609
610
610
- # excluding column axis area
611
- max_rows = get_option ("display.max_rows" ) or height
612
- return len (self ) <= min (max_rows , height )
611
+ if height is None and max_rows is None :
612
+ return True
613
+
614
+ else :
615
+ # min of two, where one may be None
616
+ height = height or max_rows + 1
617
+ max_rows = max_rows or height + 1
618
+ return len (self ) <= min (max_rows , height )
613
619
614
620
def _repr_fits_horizontal_ (self ):
615
621
"""
@@ -618,13 +624,18 @@ def _repr_fits_horizontal_(self):
618
624
boundaries apply.
619
625
"""
620
626
width , height = fmt .get_console_size ()
621
-
622
627
max_columns = get_option ("display.max_columns" )
623
628
nb_columns = len (self .columns )
629
+
630
+ # exceed max columns
624
631
if ((max_columns and nb_columns > max_columns ) or
625
- (nb_columns > (width // 2 ))):
632
+ (width and nb_columns > (width // 2 ))):
626
633
return False
627
634
635
+ if width is None :
636
+ # no sense finding width of repr if no width set
637
+ return True
638
+
628
639
buf = StringIO ()
629
640
630
641
# only care about the stuff we'll actually print out
@@ -635,7 +646,7 @@ def _repr_fits_horizontal_(self):
635
646
# min of two, where one may be None
636
647
height = height or max_rows + 1
637
648
max_rows = max_rows or height + 1
638
- d = d .iloc [:min (max_rows , height )]
649
+ d = d .iloc [:min (max_rows , height , len ( d ) )]
639
650
640
651
d .to_string (buf = buf )
641
652
value = buf .getvalue ()
@@ -1593,7 +1604,7 @@ def info(self, verbose=True, buf=None, max_cols=None):
1593
1604
1594
1605
# hack
1595
1606
if max_cols is None :
1596
- max_cols = get_option ('display.max_info_columns' )
1607
+ max_cols = get_option ('display.max_info_columns' , len ( self . columns ) + 1 )
1597
1608
1598
1609
if verbose and len (self .columns ) <= max_cols :
1599
1610
lines .append ('Data columns (total %d columns):' % len (self .columns ))
0 commit comments