File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,9 @@ def __init__(
108
108
self .cell_context : DefaultDict [tuple [int , int ], str ] = defaultdict (str )
109
109
self ._todo : list [tuple [Callable , tuple , dict ]] = []
110
110
self .tooltips : Tooltips | None = None
111
- precision = precision or get_option ("styler.format.precision" )
111
+ precision = (
112
+ get_option ("styler.format.precision" ) if precision is None else precision
113
+ )
112
114
self ._display_funcs : DefaultDict [ # maps (row, col) -> formatting function
113
115
tuple [int , int ], Callable [[Any ], str ]
114
116
] = defaultdict (lambda : partial (_default_formatter , precision = precision ))
@@ -1032,7 +1034,9 @@ def _maybe_wrap_formatter(
1032
1034
elif callable (formatter ):
1033
1035
func_0 = formatter
1034
1036
elif formatter is None :
1035
- precision = precision or get_option ("styler.format.precision" )
1037
+ precision = (
1038
+ get_option ("styler.format.precision" ) if precision is None else precision
1039
+ )
1036
1040
func_0 = partial (
1037
1041
_default_formatter , precision = precision , thousands = (thousands is not None )
1038
1042
)
Original file line number Diff line number Diff line change @@ -298,3 +298,10 @@ def test_format_options():
298
298
with option_context ("styler.format.formatter" , {"int" : "{:,.2f}" }):
299
299
ctx_with_op = df .style ._translate (True , True )
300
300
assert ctx_with_op ["body" ][0 ][1 ]["display_value" ] == "2,000.00"
301
+
302
+
303
+ def test_precision_zero (df ):
304
+ styler = Styler (df , precision = 0 )
305
+ ctx = styler ._translate (True , True )
306
+ assert ctx ["body" ][0 ][2 ]["display_value" ] == "-1"
307
+ assert ctx ["body" ][1 ][2 ]["display_value" ] == "-1"
You can’t perform that action at this time.
0 commit comments