Skip to content

DOC: fix docstring of DataFrame.to_latex, double curly braces to single #60165

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 2 commits into from
Nov 1, 2024

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