|
21 | 21 |
|
22 | 22 | from pandas._config import get_option |
23 | 23 |
|
| 24 | +from numbers import Real # Real |
| 25 | +from pandas._config import get_option # display.precision |
| 26 | + |
24 | 27 | from pandas.core.dtypes.inference import is_sequence |
25 | 28 |
|
26 | 29 | from pandas.io.formats.console import get_console_size |
@@ -168,7 +171,6 @@ def _pprint_dict( |
168 | 171 | else: |
169 | 172 | return fmt.format(things=", ".join(pairs)) |
170 | 173 |
|
171 | | - |
172 | 174 | def pprint_thing( |
173 | 175 | thing: object, |
174 | 176 | _nest_lvl: int = 0, |
@@ -201,19 +203,25 @@ def pprint_thing( |
201 | 203 | """ |
202 | 204 |
|
203 | 205 | def as_escaped_string( |
204 | | - thing: Any, escape_chars: EscapeChars | None = escape_chars |
| 206 | + thing: Any, escape_chars: EscapeChars | None = escape_chars |
205 | 207 | ) -> str: |
206 | 208 | translate = {"\t": r"\t", "\n": r"\n", "\r": r"\r", "'": r"\'"} |
207 | 209 | if isinstance(escape_chars, Mapping): |
208 | 210 | if default_escapes: |
209 | 211 | translate.update(escape_chars) |
210 | 212 | else: |
211 | | - translate = escape_chars # type: ignore[assignment] |
| 213 | + translate = escape_chars |
212 | 214 | escape_chars = list(escape_chars.keys()) |
213 | 215 | else: |
214 | 216 | escape_chars = escape_chars or () |
215 | 217 |
|
216 | | - result = str(thing) |
| 218 | + # Real instance kontrolü ve precision uygulaması |
| 219 | + if isinstance(thing, Real) and not isinstance(thing, int): |
| 220 | + precision = get_option("display.precision") |
| 221 | + result = f"{thing:.{precision}f}" |
| 222 | + else: |
| 223 | + result = str(thing) |
| 224 | + |
217 | 225 | for c in escape_chars: |
218 | 226 | result = result.replace(c, translate[c]) |
219 | 227 | return result |
|
0 commit comments