Repository: pandas-dev/pandas

Issue:
float_format in to_latex can be a function
The docs for ``to_latex(float_format=)`` say

```
float_format : str, optional
    Format string for floating point numbers.
```

and indeed the code contains a comment confirming this:

https://github.com/pandas-dev/pandas/blob/8b48f5c75a058c239a5d0eb9ee4f1593f1be1810/pandas/io/formats/format.py#L1010

... but it does accept a function:
```
In [2]: s = pd.Series(1/3, index=range(3))                                                                                                                                                                                                    

In [3]: s.to_latex(float_format='{:0.2f}'.format)                                                                                                                                                                                             
Out[3]: '\\begin{tabular}{lr}\n\\toprule\n{} &    0 \\\\\n\\midrule\n0 & 0.33 \\\\\n1 & 0.33 \\\\\n2 & 0.33 \\\\\n\\bottomrule\n\\end{tabular}\n'
```

... and ``formatters`` (mentioned in the comment above) does not apply to ``Series`` (?), and is not as convenient for ``DataFrames`` (it requires to explicitly mention each column name).

So I guess we just want to document that it can be either a string, or a function.

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit           : f58a1fee78629ad158eca41c8f228e59aae311b0
python           : 3.7.3.candidate.1
python-bits      : 64
OS               : Linux
OS-release       : 4.9.0-9-amd64
machine          : x86_64
processor        : 
byteorder        : little
LC_ALL           : None
LANG             : it_IT.UTF-8
LOCALE           : it_IT.UTF-8

pandas           : 0.25.0.dev0+854.gf58a1fee7.dirty
numpy            : 1.16.4
pytz             : 2016.7
dateutil         : 2.8.0
pip              : 9.0.1
setuptools       : 41.0.1
Cython           : 0.29.2
pytest           : 4.6.3
hypothesis       : 3.71.11
sphinx           : 1.4.9
blosc            : None
feather          : None
xlsxwriter       : 0.9.6
lxml.etree       : 4.3.2
html5lib         : 0.999999999
pymysql          : None
psycopg2         : None
jinja2           : 2.10.1
IPython          : 7.5.0
pandas_datareader: 0.2.1
bs4              : 4.5.3
bottleneck       : 1.2.1
fastparquet      : None
gcsfs            : None
lxml.etree       : 4.3.2
matplotlib       : 3.0.2
numexpr          : 2.6.9
openpyxl         : 2.3.0
pandas_gbq       : None
pyarrow          : None
pytables         : None
s3fs             : None
scipy            : 1.1.0
sqlalchemy       : 1.0.15
tables           : 3.4.4
xarray           : None
xlrd             : 1.0.0
xlwt             : 1.3.0
xlsxwriter       : 0.9.6


</details>



Discussion:
One further reason to allow functions might be that strings only support the Python 2.x syntax. - although we would probably like to change this sooner or later.

Resolving patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -2796,8 +2796,10 @@ def to_latex(self, buf=None, columns=None, col_space=None, header=True,
             Formatter functions to apply to columns' elements by position or
             name. The result of each function must be a unicode string.
             List must be of length equal to the number of columns.
-        float_format : str, optional
-            Format string for floating point numbers.
+        float_format : one-parameter function or str, optional, default None
+            Formatter for floating point numbers. For example
+            ``float_format="%%.2f"`` and ``float_format="{:0.2f}".format`` will
+            both result in 0.1234 being formatted as 0.12.
         sparsify : bool, optional
             Set to False for a DataFrame with a hierarchical index to print
             every multiindex key at each row. By default, the value will be


Test patch: