Repository: pandas-dev/pandas
Pull request: BUG: Fix FloatingArray output formatting
- [x] closes #36775
- [x] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`


Problem statement:
BUG: Nullable floats can look like ints in repr
Nullable floats when output to the screen can look like ints, but in my opinion should look the same as regular non-NaN floats so as not to cause confusion.
```python
import pandas as pd

s = pd.Series([0.0, 1.0, None], dtype="Float64")
print(s)
# 0       0
# 1       1
# 2    <NA>
# dtype: Float64
print(s.astype(float))
# 0    0.0
# 1    1.0
# 2    NaN
# dtype: float64
pd.__version__
# '1.2.0.dev0+560.g86f543143'

```
cc @jorisvandenbossche

Hints from issue discussion:

Commit message: Test

Patch to review:
diff --git a/pandas/io/formats/format.py b/pandas/io/formats/format.py
index b9d41f142c2b5..515ff168464de 100644
--- a/pandas/io/formats/format.py
+++ b/pandas/io/formats/format.py
@@ -1311,7 +1311,7 @@ def _format_strings(self) -> List[str]:
             float_format = get_option("display.float_format")
             if float_format is None:
                 precision = get_option("display.precision")
-                float_format = lambda x: f"{x: .{precision:d}g}"
+                float_format = lambda x: f"{x: .{precision:d}f}"
         else:
             float_format = self.float_format
 
@@ -1372,6 +1372,8 @@ def _format(x):
                     tpl = " {v}"
                 fmt_values.append(tpl.format(v=_format(v)))
 
+        fmt_values = _trim_zeros_float(str_floats=fmt_values, decimal=".")
+
         return fmt_values
 
 
@@ -1473,9 +1475,9 @@ def format_values_with(float_format):
 
             if self.fixed_width:
                 if is_complex:
-                    result = _trim_zeros_complex(values, self.decimal, na_rep)
+                    result = values
                 else:
-                    result = _trim_zeros_float(values, self.decimal, na_rep)
+                    result = _trim_zeros_float(values, self.decimal)
                 return np.asarray(result, dtype="object")
 
             return values
@@ -1855,21 +1857,8 @@ def just(x):
     return result
 
 
-def _trim_zeros_complex(
-    str_complexes: np.ndarray, decimal: str = ".", na_rep: str = "NaN"
-) -> List[str]:
-    """
-    Separates the real and imaginary parts from the complex number, and
-    executes the _trim_zeros_float method on each of those.
-    """
-    return [
-        "".join(_trim_zeros_float(re.split(r"([j+-])", x), decimal, na_rep))
-        for x in str_complexes
-    ]
-
-
 def _trim_zeros_float(
-    str_floats: Union[np.ndarray, List[str]], decimal: str = ".", na_rep: str = "NaN"
+    str_floats: Union[np.ndarray, List[str]], decimal: str = "."
 ) -> List[str]:
     """
     Trims zeros, leaving just one before the decimal points if need be.
@@ -1877,7 +1866,7 @@ def _trim_zeros_float(
     trimmed = str_floats
 
     def _is_number(x):
-        return x != na_rep and not x.endswith("inf")
+        return re.match(r"\s*-?[0-9]+(\.[0-9]*)?", x) is not None
 
     def _cond(values):
         finite = [x for x in values if _is_number(x)]
diff --git a/pandas/tests/io/formats/test_format.py b/pandas/tests/io/formats/test_format.py
index 68f5386fff7be..d57ed96effe37 100644
--- a/pandas/tests/io/formats/test_format.py
+++ b/pandas/tests/io/formats/test_format.py
@@ -3432,3 +3432,14 @@ def test_format_remove_leading_space_dataframe(input_array, expected):
     # GH: 24980
     df = pd.DataFrame(input_array).to_string(index=False)
     assert df == expected
+
+
+@pytest.mark.parametrize("dtype", ["Float32", "Float64"])
+def test_nullable_float_to_string(dtype):
+    # https://github.com/pandas-dev/pandas/issues/36775
+    s = pd.Series([0.0, 1.0, None], dtype=dtype)
+    result = s.to_string()
+    expected = """0     0.0
+1     1.0
+2    <NA>"""
+    assert result == expected


Code review comments:
diff_hunk: @@ -3432,3 +3432,14 @@ def test_format_remove_leading_space_dataframe(input_array, expected):
     # GH: 24980
     df = pd.DataFrame(input_array).to_string(index=False)
     assert df == expected
+
+
+@pytest.mark.parametrize("dtype", ["Float32", "Float64"])
path: pandas/tests/io/formats/test_format.py
text: @user1:
can you use the fixture