Skip to content

Conversation

yuanx749
Copy link
Contributor

@yuanx749 yuanx749 commented Nov 1, 2024

The parameters docstring of to_latex is misleading. For example, float_format="{{:0.2f}}".format should rather use single curly brace, as the example in the docstring

>>> df = pd.DataFrame(dict(name=['Raphael', 'Donatello'],
...                        age=[26, 45],
...                        height=[181.23, 177.65]))
>>> print(df.to_latex(index=False,
...                   formatters={"name": str.upper},
...                   float_format="{:.1f}".format,
...                   ))  
\begin{tabular}{lrr}
\toprule
name & age & height \\
\midrule
RAPHAEL & 26 & 181.2 \\
DONATELLO & 45 & 177.7 \\
\bottomrule
\end{tabular}

This PR replaces {{}} with {} in to_latex docstring.

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@mroeschke mroeschke added the Docs label Nov 1, 2024
@mroeschke mroeschke added this to the 3.0 milestone Nov 1, 2024
@mroeschke mroeschke merged commit d48235f into pandas-dev:main Nov 1, 2024
54 of 55 checks passed
@mroeschke
Copy link
Member

Thanks @yuanx749

@yuanx749 yuanx749 deleted the to_latex-doc branch November 2, 2024 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants