(self)
| 307 | ) |
| 308 | |
| 309 | def to_string(self) -> str: |
| 310 | series = self.tr_series |
| 311 | footer = self._get_footer() |
| 312 | |
| 313 | if len(series) == 0: |
| 314 | return f"{type(self.series).__name__}([], {footer})" |
| 315 | |
| 316 | index = series.index |
| 317 | have_header = _has_names(index) |
| 318 | if isinstance(index, MultiIndex): |
| 319 | fmt_index = index._format_multi(include_names=True, sparsify=None) |
| 320 | adj = printing.get_adjustment() |
| 321 | fmt_index = adj.adjoin(2, *fmt_index).split("\n") |
| 322 | else: |
| 323 | fmt_index = index._format_flat(include_name=True) |
| 324 | fmt_values = self._get_formatted_values() |
| 325 | |
| 326 | if self.is_truncated_vertically: |
| 327 | n_header_rows = 0 |
| 328 | row_num = self.tr_row_num |
| 329 | row_num = cast(int, row_num) |
| 330 | width = self.adj.len(fmt_values[row_num - 1]) |
| 331 | if width > 3: |
| 332 | dot_str = "..." |
| 333 | else: |
| 334 | dot_str = ".." |
| 335 | # Series uses mode=center because it has single value columns |
| 336 | # DataFrame uses mode=left |
| 337 | dot_str = self.adj.justify([dot_str], width, mode="center")[0] |
| 338 | fmt_values.insert(row_num + n_header_rows, dot_str) |
| 339 | fmt_index.insert(row_num + 1, "") |
| 340 | |
| 341 | if self.index: |
| 342 | result = self.adj.adjoin(3, *[fmt_index[1:], fmt_values]) |
| 343 | else: |
| 344 | result = self.adj.adjoin(3, fmt_values) |
| 345 | |
| 346 | if self.header and have_header: |
| 347 | result = fmt_index[0] + "\n" + result |
| 348 | |
| 349 | if footer: |
| 350 | result += "\n" + footer |
| 351 | |
| 352 | return str("".join(result)) |
| 353 | |
| 354 | |
| 355 | def get_dataframe_repr_params() -> dict[str, Any]: |
no test coverage detected