-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add pl.DataFrame.to_markdown #13907
Comments
I also received a feature request to cast to HTML; if one is accepted then the other would be pretty much straighforward. |
doesn't |
Another (less-effort) implementation: import polars as pl
import io
def to_markdown(df: pl.DataFrame) -> str:
buf = io.StringIO()
with pl.Config(
tbl_formatting="ASCII_MARKDOWN",
tbl_hide_column_data_types=True,
tbl_hide_dataframe_shape=True,
):
print(df, file=buf)
buf.seek(0)
return buf.read() One may need more config options like |
pandas does this by deferring to |
@MarcoGorelli I thought the opposite trying to implement pyarrow table support to it a while ago; the way |
Nice one; I think it's relatively unknown, but the @pl.Config(
tbl_formatting = "ASCII_MARKDOWN",
tbl_hide_column_data_types = True,
tbl_hide_dataframe_shape = True,
)
def frame_to_markdown( df: pl.DataFrame ) -> str:
return str(df) If we could add left/right/center align options to the markdown output we'd have the basics covered at least 🤔 Footnotes |
Description
It'd be good to have a
to_markdown
method at the dataframe level.The string repr is almost right, just needs some tweeking to be valid markdown.
A very bad implementation in Python would be:
The text was updated successfully, but these errors were encountered: