Skip to content

TST: Create test for #30122 about display.precision #45185

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 4 commits into from
Jan 8, 2022
Merged
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2874,6 +2874,25 @@ def test_output_display_precision_trailing_zeroes(self):
expected_output = "0 840\n1 4200\ndtype: float64"
assert str(s) == expected_output

@pytest.mark.parametrize(
"value,expected",
[
([9.4444], " 0\n0 9"),
([0.49], " 0\n0 5e-01"),
([10.9999], " 0\n0 11"),
([9.5444, 9.6], " 0\n0 10\n1 10"),
([0.46, 0.78, -9.9999], " 0\n0 5e-01\n1 8e-01\n2 -1e+01"),
],
)
def test_set_option_precision(self, value, expected):
# Issue #30122
# Precision was incorrectly shown

with option_context("display.precision", 0):

df_value = DataFrame(value)
assert str(df_value) == expected

def test_output_significant_digits(self):
# Issue #9764

Expand Down