@@ -544,14 +544,22 @@ def __repr__(self) -> str:
544
544
return object .__repr__ (self )
545
545
546
546
def _repr_html_ (self ) -> str :
547
+ max_groups = get_option ("display.max_groups" )
548
+ ngroups = self .ngroups
549
+ n_start = (max_groups + 1 ) // 2
550
+ n_end = max_groups - n_start
547
551
repr_html = ""
548
- for group_name , group in self :
549
- if not hasattr (group , "to_html" ):
550
- group = group .to_frame ()
551
- repr_html += f"<H3>Group Key: { group_name } <H3/>"
552
- repr_html += group .to_html (
553
- max_rows = get_option ("display.max_rows" ) // self .ngroups
554
- )
552
+ truncated = ngroups > max_groups
553
+ for k , (group_name , group ) in enumerate (self ):
554
+ if not truncated or (n_start > k or k >= ngroups - n_end ):
555
+ if not hasattr (group , "to_html" ):
556
+ group = group .to_frame ()
557
+ repr_html += f"<H3>Group Key: { group_name } <H3/>"
558
+ repr_html += group .to_html (
559
+ max_rows = max (1 , get_option ("display.max_rows" ) // self .ngroups )
560
+ )
561
+ elif k == max_groups // 2 :
562
+ repr_html += "<H3>...<H3/>"
555
563
return repr_html
556
564
557
565
def _assure_grouper (self ):
0 commit comments