@@ -1158,6 +1158,7 @@ def test_display_format_raises(self):
1158
1158
df .style .format (True )
1159
1159
1160
1160
def test_display_set_precision (self ):
1161
+ # Issue #13257
1161
1162
df = pd .DataFrame (data = [[1.0 , 2.0090 ], [3.2121 , 4.566 ]], columns = ["a" , "b" ])
1162
1163
s = Styler (df )
1163
1164
@@ -1189,22 +1190,18 @@ def test_display_subset(self):
1189
1190
{"a" : "{:0.1f}" , "b" : "{0:.2%}" }, subset = pd .IndexSlice [0 , :]
1190
1191
)._translate ()
1191
1192
expected = "0.1"
1192
- assert ctx ["body" ][0 ][1 ]["display_value" ] == expected
1193
- assert ctx ["body" ][1 ][1 ]["display_value" ] == "1.1234"
1194
- assert ctx ["body" ][0 ][2 ]["display_value" ] == "12.34%"
1195
-
1196
- raw_11 = "1.1234"
1197
- ctx = df .style .format ("{:0.1f}" , subset = pd .IndexSlice [0 , :])._translate ()
1193
+ raw_11 = "1.123400"
1198
1194
assert ctx ["body" ][0 ][1 ]["display_value" ] == expected
1199
1195
assert ctx ["body" ][1 ][1 ]["display_value" ] == raw_11
1196
+ assert ctx ["body" ][0 ][2 ]["display_value" ] == "12.34%"
1200
1197
1201
1198
ctx = df .style .format ("{:0.1f}" , subset = pd .IndexSlice [0 , :])._translate ()
1202
1199
assert ctx ["body" ][0 ][1 ]["display_value" ] == expected
1203
1200
assert ctx ["body" ][1 ][1 ]["display_value" ] == raw_11
1204
1201
1205
1202
ctx = df .style .format ("{:0.1f}" , subset = pd .IndexSlice ["a" ])._translate ()
1206
1203
assert ctx ["body" ][0 ][1 ]["display_value" ] == expected
1207
- assert ctx ["body" ][0 ][2 ]["display_value" ] == "0.1234 "
1204
+ assert ctx ["body" ][0 ][2 ]["display_value" ] == "0.123400 "
1208
1205
1209
1206
ctx = df .style .format ("{:0.1f}" , subset = pd .IndexSlice [0 , "a" ])._translate ()
1210
1207
assert ctx ["body" ][0 ][1 ]["display_value" ] == expected
@@ -1215,8 +1212,8 @@ def test_display_subset(self):
1215
1212
)._translate ()
1216
1213
assert ctx ["body" ][0 ][1 ]["display_value" ] == expected
1217
1214
assert ctx ["body" ][1 ][1 ]["display_value" ] == "1.1"
1218
- assert ctx ["body" ][0 ][2 ]["display_value" ] == "0.1234 "
1219
- assert ctx ["body" ][1 ][2 ]["display_value" ] == "1.1234"
1215
+ assert ctx ["body" ][0 ][2 ]["display_value" ] == "0.123400 "
1216
+ assert ctx ["body" ][1 ][2 ]["display_value" ] == raw_11
1220
1217
1221
1218
def test_display_dict (self ):
1222
1219
df = pd .DataFrame ([[0.1234 , 0.1234 ], [1.1234 , 1.1234 ]], columns = ["a" , "b" ])
0 commit comments