@@ -989,15 +989,13 @@ def __repr__(self) -> str:
989
989
"""
990
990
Return a string representation for a particular DataFrame.
991
991
"""
992
- buf = StringIO ("" )
993
992
if self ._info_repr ():
993
+ buf = StringIO ("" )
994
994
self .info (buf = buf )
995
995
return buf .getvalue ()
996
996
997
997
repr_params = fmt .get_dataframe_repr_params ()
998
- self .to_string (buf = buf , ** repr_params )
999
-
1000
- return buf .getvalue ()
998
+ return self .to_string (** repr_params )
1001
999
1002
1000
def _repr_html_ (self ) -> str | None :
1003
1001
"""
@@ -1043,6 +1041,56 @@ def _repr_html_(self) -> str | None:
1043
1041
else :
1044
1042
return None
1045
1043
1044
+ @overload
1045
+ def to_string (
1046
+ self ,
1047
+ buf : None = None ,
1048
+ columns : Sequence [str ] | None = None ,
1049
+ col_space : int | None = None ,
1050
+ header : bool | Sequence [str ] = True ,
1051
+ index : bool = True ,
1052
+ na_rep : str = "NaN" ,
1053
+ formatters : fmt .FormattersType | None = None ,
1054
+ float_format : fmt .FloatFormatType | None = None ,
1055
+ sparsify : bool | None = None ,
1056
+ index_names : bool = True ,
1057
+ justify : str | None = None ,
1058
+ max_rows : int | None = None ,
1059
+ min_rows : int | None = None ,
1060
+ max_cols : int | None = None ,
1061
+ show_dimensions : bool = False ,
1062
+ decimal : str = "." ,
1063
+ line_width : int | None = None ,
1064
+ max_colwidth : int | None = None ,
1065
+ encoding : str | None = None ,
1066
+ ) -> str :
1067
+ ...
1068
+
1069
+ @overload
1070
+ def to_string (
1071
+ self ,
1072
+ buf : FilePathOrBuffer [str ],
1073
+ columns : Sequence [str ] | None = None ,
1074
+ col_space : int | None = None ,
1075
+ header : bool | Sequence [str ] = True ,
1076
+ index : bool = True ,
1077
+ na_rep : str = "NaN" ,
1078
+ formatters : fmt .FormattersType | None = None ,
1079
+ float_format : fmt .FloatFormatType | None = None ,
1080
+ sparsify : bool | None = None ,
1081
+ index_names : bool = True ,
1082
+ justify : str | None = None ,
1083
+ max_rows : int | None = None ,
1084
+ min_rows : int | None = None ,
1085
+ max_cols : int | None = None ,
1086
+ show_dimensions : bool = False ,
1087
+ decimal : str = "." ,
1088
+ line_width : int | None = None ,
1089
+ max_colwidth : int | None = None ,
1090
+ encoding : str | None = None ,
1091
+ ) -> None :
1092
+ ...
1093
+
1046
1094
@Substitution (
1047
1095
header_type = "bool or sequence" ,
1048
1096
header = "Write out the column names. If a list of strings "
0 commit comments