Skip to content

BUG: Fix FloatingArray output formatting #36800

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 28 commits into from
Oct 16, 2020
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ca6c979
BUG: Fix FloatingArray output formatting
dsaxton Oct 1, 2020
adcc26c
fixup
dsaxton Oct 1, 2020
4663e10
fixup
dsaxton Oct 1, 2020
406ed4d
CLN: Clean float / complex string formatting
dsaxton Oct 2, 2020
a1228c9
Fix
dsaxton Oct 2, 2020
04f4be8
Merge branch 'fix-is-numeric-helper' into nullable-float-array-string…
dsaxton Oct 2, 2020
77b88fc
Test
dsaxton Oct 2, 2020
8743b5b
Test
dsaxton Oct 2, 2020
a235611
Fixture
dsaxton Oct 2, 2020
d775c33
Update format.py
dsaxton Oct 11, 2020
00c15ba
Reapply
dsaxton Oct 11, 2020
06ef337
Update
dsaxton Oct 11, 2020
aedd7ab
Merge remote-tracking branch 'upstream/master' into nullable-float-ar…
dsaxton Oct 11, 2020
32264e9
Hack
dsaxton Oct 12, 2020
ba3ac46
Simplify
dsaxton Oct 12, 2020
f8a3216
Fix regex
dsaxton Oct 12, 2020
546b44e
Fix doc
dsaxton Oct 12, 2020
99d6905
Fix
dsaxton Oct 12, 2020
319529f
Again
dsaxton Oct 12, 2020
f65bcfe
Merge remote-tracking branch 'upstream/master' into nullable-float-ar…
dsaxton Oct 14, 2020
7a477dc
Fix merge
dsaxton Oct 14, 2020
13567f8
Merge remote-tracking branch 'upstream/master' into nullable-float-ar…
dsaxton Oct 14, 2020
253c94e
Merge remote-tracking branch 'upstream/master' into nullable-float-ar…
dsaxton Oct 14, 2020
2136494
Merge remote-tracking branch 'upstream/master' into nullable-float-ar…
dsaxton Oct 15, 2020
7d4452a
Type and doc
dsaxton Oct 15, 2020
80b0103
Oops
dsaxton Oct 15, 2020
faa053f
Merge remote-tracking branch 'upstream/master' into nullable-float-ar…
dsaxton Oct 15, 2020
8fd5a9f
Add tests
dsaxton Oct 15, 2020
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
Simplify
  • Loading branch information
dsaxton committed Oct 12, 2020
commit ba3ac468479edae5eb9db99771924d68099c026b
10 changes: 3 additions & 7 deletions pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -1891,18 +1891,14 @@ def _trim_zeros_float(
Trims zeros, leaving just one before the decimal points if need be.
"""
trimmed = str_floats
number_regex = re.compile(r"\s*[\+-]?[0-9]+[\.,]?([0-9]*)?")
number_regex = re.compile(fr"^\s*[\+-]?[0-9]+\{decimal}([0-9]*)?$")

def is_number_with_decimal(x):
return re.match(number_regex, x) is not None and decimal in x
return re.match(number_regex, x) is not None

def should_trim(values):
numbers = [x for x in values if is_number_with_decimal(x)]
return (
len(numbers) > 0
and all(x.endswith("0") for x in numbers)
and not any(("e" in x) or ("E" in x) for x in numbers)
)
return len(numbers) > 0 and all(x.endswith("0") for x in numbers)

while should_trim(trimmed):
trimmed = [
Expand Down