@@ -483,6 +483,37 @@ def get_adjustment() -> TextAdjustment:
483
483
return TextAdjustment ()
484
484
485
485
486
+ def get_dataframe_repr_params () -> dict [str , Any ]:
487
+ """Get the parameters used to repr(dataFrame) calls using DataFrame.to_string.
488
+
489
+ Supplying these parameters to DataFrame.to_string is equivalent to calling
490
+ ``repr(DataFrame)``. This is useful if you want to adjust the repr output.
491
+
492
+ Example
493
+ -------
494
+ >>> import pandas as pd
495
+ >>>
496
+ >>> df = pd.DataFrame([[1, 2], [3, 4]])
497
+ >>> repr_params = pd.io.formats.format.get_dataframe_repr_params()
498
+ >>> repr(df) == df.to_string(**repr_params)
499
+ True
500
+ """
501
+ from pandas .io .formats import console
502
+
503
+ if get_option ("display.expand_frame_repr" ):
504
+ line_width , _ = console .get_console_size ()
505
+ else :
506
+ line_width = None
507
+ return {
508
+ "max_rows" : get_option ("display.max_rows" ),
509
+ "min_rows" : get_option ("display.min_rows" ),
510
+ "max_cols" : get_option ("display.max_columns" ),
511
+ "max_colwidth" : get_option ("display.max_colwidth" ),
512
+ "show_dimensions" : get_option ("display.show_dimensions" ),
513
+ "line_width" : line_width ,
514
+ }
515
+
516
+
486
517
class DataFrameFormatter :
487
518
"""Class for processing dataframe formatting options and data."""
488
519
0 commit comments