@@ -489,6 +489,8 @@ def get_dataframe_repr_params() -> dict[str, Any]:
489489 Supplying these parameters to DataFrame.to_string is equivalent to calling
490490 ``repr(DataFrame)``. This is useful if you want to adjust the repr output.
491491
492+ .. versionadded:: 1.4.0
493+
492494 Example
493495 -------
494496 >>> import pandas as pd
@@ -514,6 +516,44 @@ def get_dataframe_repr_params() -> dict[str, Any]:
514516 }
515517
516518
519+ def get_series_repr_params (series : Series ) -> dict [str , Any ]:
520+ """Get the parameters used to repr(Series) calls using Series.to_string.
521+
522+ Supplying these parameters to Series.to_string is equivalent to calling
523+ ``repr(series)``. This is useful if you want to adjust the series repr output.
524+
525+ .. versionadded:: 1.4.0
526+
527+ Example
528+ -------
529+ >>> import pandas as pd
530+ >>>
531+ >>> ser = pd.Series([1, 2, 3, 4])
532+ >>> repr_params = pd.io.formats.format.get_series_repr_params(ser)
533+ >>> repr(ser) == ser.to_string(**repr_params)
534+ True
535+ """
536+ width , height = get_terminal_size ()
537+ max_rows = (
538+ height
539+ if get_option ("display.max_rows" ) == 0
540+ else get_option ("display.max_rows" )
541+ )
542+ min_rows = (
543+ height
544+ if get_option ("display.max_rows" ) == 0
545+ else get_option ("display.min_rows" )
546+ )
547+
548+ return {
549+ "name" : series .name ,
550+ "dtype" : series .dtype ,
551+ "min_rows" : min_rows ,
552+ "max_rows" : max_rows ,
553+ "length" : get_option ("display.show_dimensions" ),
554+ }
555+
556+
517557class DataFrameFormatter :
518558 """Class for processing dataframe formatting options and data."""
519559
0 commit comments