Skip to content

Commit f5b3f3e

Browse files
author
Tuhin-SnapD
committed
BUG: Preserve full float precision when double_precision=15 in to_json; fix DataFrame element-wise mapping without applymap (#62072)
1 parent 8cd9e1f commit f5b3f3e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pandas/io/json/_json.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ def _stringify_floats_full_precision(obj: Any) -> Any:
120120
if isinstance(obj, Series):
121121
return obj.map(_format_float_full_precision)
122122
if isinstance(obj, DataFrame):
123-
return obj.applymap(_format_float_full_precision)
123+
# Apply element-wise via Series.map to avoid deprecated/removed applymap
124+
return obj.apply(lambda s: s.map(_format_float_full_precision))
124125
if isinstance(obj, dict):
125126
return {k: _stringify_floats_full_precision(v) for k, v in obj.items()}
126127
if isinstance(obj, list):
@@ -130,6 +131,7 @@ def _stringify_floats_full_precision(obj: Any) -> Any:
130131
# Scalars
131132
return _format_float_full_precision(obj)
132133

134+
133135
# interface to/from
134136
@overload
135137
def to_json(

0 commit comments

Comments
 (0)