We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
missingval
np.nan
None
Related to
The missingval argument doesn't recognise np.nan values, it only recognises None
import pandas import numpy as np from tabulate import tabulate df = pandas.DataFrame({"x": [1, 2], "y": [0, np.nan]}) print(tabulate(df,floatfmt=".0f", missingval="-",tablefmt="grid")) -- +---+---+-----+ | 0 | 1 | 0 | +---+---+-----+ | 1 | 2 | nan | +---+---+-----+ In [6]: print(tabulate(df.replace(np.nan, None),floatfmt=".0f", missingval="-",tablefmt="grid")) +---+---+---+ | 0 | 1 | 0 | +---+---+---+ | 1 | 2 | - | +---+---+---+
Note: In practice I use the data frame .to_markdown() methods which calls tabulate in the background, as explained in the pandas documentation of DataFrame.to_markdown
.to_markdown()
In [7]: print(df.to_markdown(floatfmt=".0f", index=False, missingval="-")) | x | y | |----:|----:| | 1 | 0 | | 2 | nan | In [8]: print(df.replace(np.nan, None).to_markdown(floatfmt=".0f", index=False, missingval="-")) | x | y | |----:|----:| | 1 | 0 | | 2 | - |
The missingval argument should recognise np.nan as a missing value. This would help avoid having to replace them with df.replace(np.nan, None).
df.replace(np.nan, None)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Related to
Current behaviour
The
missingval
argument doesn't recognisenp.nan
values, it only recognisesNone
Note: In practice I use the data frame
.to_markdown()
methods which calls tabulate in the background, as explained in the pandas documentation of DataFrame.to_markdownProposed behaviour
The
missingval
argument should recognisenp.nan
as a missing value. This would help avoid having to replace them withdf.replace(np.nan, None)
.The text was updated successfully, but these errors were encountered: