|
15 | 15 |
|
16 | 16 | import numpy as np
|
17 | 17 |
|
18 |
| -from pandas._config import get_option |
19 |
| - |
20 | 18 | from pandas._libs import lib
|
21 | 19 | from pandas._libs.interval import (
|
22 | 20 | VALID_CLOSED,
|
@@ -1233,43 +1231,10 @@ def value_counts(self, dropna: bool = True) -> Series:
|
1233 | 1231 | # ---------------------------------------------------------------------
|
1234 | 1232 | # Rendering Methods
|
1235 | 1233 |
|
1236 |
| - def _format_data(self) -> str: |
1237 |
| - # TODO: integrate with categorical and make generic |
1238 |
| - n = len(self) |
1239 |
| - max_seq_items = min((get_option("display.max_seq_items") or n) // 10, 10) |
1240 |
| - |
1241 |
| - formatter = str |
1242 |
| - |
1243 |
| - if n == 0: |
1244 |
| - summary = "[]" |
1245 |
| - elif n == 1: |
1246 |
| - first = formatter(self[0]) |
1247 |
| - summary = f"[{first}]" |
1248 |
| - elif n == 2: |
1249 |
| - first = formatter(self[0]) |
1250 |
| - last = formatter(self[-1]) |
1251 |
| - summary = f"[{first}, {last}]" |
1252 |
| - else: |
1253 |
| - if n > max_seq_items: |
1254 |
| - n = min(max_seq_items // 2, 10) |
1255 |
| - head = [formatter(x) for x in self[:n]] |
1256 |
| - tail = [formatter(x) for x in self[-n:]] |
1257 |
| - head_str = ", ".join(head) |
1258 |
| - tail_str = ", ".join(tail) |
1259 |
| - summary = f"[{head_str} ... {tail_str}]" |
1260 |
| - else: |
1261 |
| - tail = [formatter(x) for x in self] |
1262 |
| - tail_str = ", ".join(tail) |
1263 |
| - summary = f"[{tail_str}]" |
1264 |
| - |
1265 |
| - return summary |
1266 |
| - |
1267 |
| - def __repr__(self) -> str: |
1268 |
| - data = self._format_data() |
1269 |
| - class_name = f"<{type(self).__name__}>\n" |
1270 |
| - |
1271 |
| - template = f"{class_name}{data}\nLength: {len(self)}, dtype: {self.dtype}" |
1272 |
| - return template |
| 1234 | + def _formatter(self, boxed: bool = False): |
| 1235 | + # returning 'str' here causes us to render as e.g. "(0, 1]" instead of |
| 1236 | + # "Interval(0, 1, closed='right')" |
| 1237 | + return str |
1273 | 1238 |
|
1274 | 1239 | # ---------------------------------------------------------------------
|
1275 | 1240 | # Vectorized Interval Properties/Attributes
|
|
0 commit comments