Skip to content

DEPR: Styler.set_na_rep and .set_precision in favour of .format(na_rep='x', precision=3) #40134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Mar 5, 2021
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
971fb40
bug: formatter overwrites na_rep
attack68 Feb 25, 2021
6f573ee
bug: formatter overwrites na_rep
attack68 Feb 25, 2021
f50f894
bug: formatter overwrites na_rep
attack68 Feb 25, 2021
47c4021
bug: formatter overwrites na_rep
attack68 Feb 25, 2021
7371e44
bug: formatter overwrites na_rep
attack68 Feb 25, 2021
82474b1
group tests
attack68 Feb 25, 2021
9a9a39b
revert small chg
attack68 Feb 25, 2021
f72b335
docs
attack68 Feb 25, 2021
0792393
test
attack68 Feb 25, 2021
7bb1171
mypy
attack68 Feb 25, 2021
0d67562
mypy
attack68 Feb 25, 2021
384916d
easy compare
attack68 Feb 25, 2021
76a44ae
easy compare
attack68 Feb 25, 2021
e3d4daf
easy compare
attack68 Feb 25, 2021
63532af
Merge remote-tracking branch 'upstream/master' into fix_formatter_na_rep
attack68 Feb 27, 2021
7bc66eb
deprecate set_na_rep() and set_precision() in favour of format()
attack68 Feb 28, 2021
518405c
edit
attack68 Feb 28, 2021
f3b38ae
edit
attack68 Feb 28, 2021
ae88c55
edit
attack68 Feb 28, 2021
859125f
edit
attack68 Feb 28, 2021
c34083e
docs
attack68 Feb 28, 2021
60a25ff
docs
attack68 Feb 28, 2021
7a64724
same var names
attack68 Mar 1, 2021
4c68cc9
same var names
attack68 Mar 1, 2021
c385a62
same var names
attack68 Mar 1, 2021
61e367a
doc examples
attack68 Mar 1, 2021
c664118
Merge remote-tracking branch 'upstream/master' into depr_format_na_rep
attack68 Mar 1, 2021
a880754
doc examples
attack68 Mar 1, 2021
ed5b13a
typing
attack68 Mar 1, 2021
27fb8d5
typing
attack68 Mar 1, 2021
88fc84d
Merge remote-tracking branch 'upstream/master' into depr_format_na_rep
attack68 Mar 2, 2021
bf7f9fc
req changes
attack68 Mar 3, 2021
892df77
req changes
attack68 Mar 3, 2021
b63220b
tests
attack68 Mar 3, 2021
fbe8bb2
whats new
attack68 Mar 3, 2021
302924c
req changes
attack68 Mar 4, 2021
43b8fa7
test clear
attack68 Mar 4, 2021
672f42c
Merge remote-tracking branch 'upstream/master' into depr_format_na_rep
attack68 Mar 5, 2021
482506c
Merge branch 'master' into depr_format_na_rep
jreback Mar 5, 2021
2c7d647
Update doc/source/whatsnew/v1.3.0.rst
attack68 Mar 5, 2021
aa51fe0
Update pandas/io/formats/style.py
attack68 Mar 5, 2021
d26d761
Update pandas/io/formats/style.py
attack68 Mar 5, 2021
94370d8
format docstring
attack68 Mar 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests
  • Loading branch information
attack68 committed Mar 3, 2021
commit b63220bd173f88f06de1073a496fc11b8efeecd2
8 changes: 4 additions & 4 deletions pandas/tests/io/formats/style/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,11 @@ def test_display_format(self):
assert len(ctx["body"][0][1]["display_value"].lstrip("-")) <= 3

@pytest.mark.parametrize("formatter", [5, True, [2.0]])
def test_display_format_raises(self, formatter):
def test_format_raises(self, formatter):
with pytest.raises(TypeError, match="expected str or callable"):
self.df.style.format(formatter)

def test_display_set_precision(self):
def test_format_with_precision(self):
# Issue #13257
df = DataFrame(data=[[1.0, 2.0090], [3.2121, 4.566]], columns=["a", "b"])
s = Styler(df)
Expand All @@ -732,7 +732,7 @@ def test_display_set_precision(self):
assert ctx["body"][1][1]["display_value"] == "3.212"
assert ctx["body"][1][2]["display_value"] == "4.566"

def test_display_subset(self):
def test_format_subset(self):
df = DataFrame([[0.1234, 0.1234], [1.1234, 1.1234]], columns=["a", "b"])
ctx = df.style.format(
{"a": "{:0.1f}", "b": "{0:.2%}"}, subset=pd.IndexSlice[0, :]
Expand Down Expand Up @@ -763,7 +763,7 @@ def test_display_subset(self):
assert ctx["body"][0][2]["display_value"] == "0.123400"
assert ctx["body"][1][2]["display_value"] == raw_11

def test_display_dict(self):
def test_format_dict(self):
df = DataFrame([[0.1234, 0.1234], [1.1234, 1.1234]], columns=["a", "b"])
ctx = df.style.format({"a": "{:0.1f}", "b": "{0:.2%}"})._translate()
assert ctx["body"][0][1]["display_value"] == "0.1"
Expand Down