Skip to content

DataFrame.to_latex() should honor na_rep after formatter. #9046

Closed
@moorepants

Description

@moorepants

In the example below I would expect that 'np.nan' would be replaced by 'aaah'.

In [3]: df = pd.DataFrame({'a': np.arange(3), 'b': [0.1, np.nan, 0.2]})

In [4]: df
Out[4]: 
   a    b
0  0  0.1
1  1  NaN
2  2  0.2

In [5]: print(df.to_latex(formatters={'b': lambda x: '{:0.4f}'.format(x)}, na_rep='aaah'))
\begin{tabular}{lrr}
\toprule
{} &  a &      b \\
\midrule
0 &  0 & 0.1000 \\
1 &  1 &    nan \\
2 &  2 & 0.2000 \\
\bottomrule
\end{tabular}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO LaTeXto_latexMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions