7979 * unset.
8080 max_rows : int, optional
8181 Maximum number of rows to display in the console.
82+ min_rows : int, optional
83+ The number of rows to display in the console in a truncated repr
84+ (when number of rows is above `max_rows`).
8285 max_cols : int, optional
8386 Maximum number of columns to display in the console.
8487 show_dimensions : bool, default False
@@ -159,7 +162,7 @@ class SeriesFormatter:
159162
160163 def __init__ (self , series , buf = None , length = True , header = True , index = True ,
161164 na_rep = 'NaN' , name = False , float_format = None , dtype = True ,
162- max_rows = None ):
165+ max_rows = None , min_rows = None ):
163166 self .series = series
164167 self .buf = buf if buf is not None else StringIO ()
165168 self .name = name
@@ -168,6 +171,7 @@ def __init__(self, series, buf=None, length=True, header=True, index=True,
168171 self .length = length
169172 self .index = index
170173 self .max_rows = max_rows
174+ self .min_rows = min_rows
171175
172176 if float_format is None :
173177 float_format = get_option ("display.float_format" )
@@ -179,10 +183,17 @@ def __init__(self, series, buf=None, length=True, header=True, index=True,
179183
180184 def _chk_truncate (self ):
181185 from pandas .core .reshape .concat import concat
186+ min_rows = self .min_rows
182187 max_rows = self .max_rows
188+ # truncation determined by max_rows, actual truncated number of rows
189+ # used below by min_rows
183190 truncate_v = max_rows and (len (self .series ) > max_rows )
184191 series = self .series
185192 if truncate_v :
193+ if min_rows :
194+ # if min_rows is set (not None or 0), set max_rows to minimum
195+ # of both
196+ max_rows = min (min_rows , max_rows )
186197 if max_rows == 1 :
187198 row_num = max_rows
188199 series = series .iloc [:max_rows ]
@@ -391,8 +402,8 @@ def __init__(self, frame, buf=None, columns=None, col_space=None,
391402 header = True , index = True , na_rep = 'NaN' , formatters = None ,
392403 justify = None , float_format = None , sparsify = None ,
393404 index_names = True , line_width = None , max_rows = None ,
394- max_cols = None , show_dimensions = False , decimal = '.' ,
395- table_id = None , render_links = False , ** kwds ):
405+ min_rows = None , max_cols = None , show_dimensions = False ,
406+ decimal = '.' , table_id = None , render_links = False , ** kwds ):
396407 self .frame = frame
397408 if buf is not None :
398409 self .buf = _expand_user (_stringify_path (buf ))
@@ -414,6 +425,7 @@ def __init__(self, frame, buf=None, columns=None, col_space=None,
414425 self .index = index
415426 self .line_width = line_width
416427 self .max_rows = max_rows
428+ self .min_rows = min_rows
417429 self .max_cols = max_cols
418430 self .max_rows_displayed = min (max_rows or len (self .frame ),
419431 len (self .frame ))
@@ -471,6 +483,10 @@ def _chk_truncate(self):
471483 max_rows = h
472484
473485 if not hasattr (self , 'max_rows_adj' ):
486+ if max_rows :
487+ if (len (self .frame ) > max_rows ) and self .min_rows :
488+ # if truncated, set max_rows showed to min_rows
489+ max_rows = min (self .min_rows , max_rows )
474490 self .max_rows_adj = max_rows
475491 if not hasattr (self , 'max_cols_adj' ):
476492 self .max_cols_adj = max_cols
0 commit comments