Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.DataFrame.to_markdown#

DataFrame.to_markdown(buf=None,*,mode='wt',index=True,storage_options=None,**kwargs)[source]#

Print DataFrame in Markdown-friendly format.

Parameters:
bufstr, Path or StringIO-like, optional, default None

Buffer to write to. If None, the output is returned as a string.

modestr, optional

Mode in which file is opened, “wt” by default.

indexbool, optional, default True

Add index (row) labels.

storage_optionsdict, optional

Extra options that make sense for a particular storage connection, e.g.host, port, username, password, etc. For HTTP(S) URLs the key-value pairsare forwarded tourllib.request.Request as header options. For otherURLs (e.g. starting with “s3://”, and “gcs://”) the key-value pairs areforwarded tofsspec.open. Please seefsspec andurllib for moredetails, and for more examples on storage options referhere.

**kwargs

These parameters will be passed totabulate.

Returns:
str

DataFrame in Markdown-friendly format.

Notes

Requires thetabulate package.

Examples

>>>df=pd.DataFrame(...data={"animal_1":["elk","pig"],"animal_2":["dog","quetzal"]}...)>>>print(df.to_markdown())|    | animal_1   | animal_2   ||---:|:-----------|:-----------||  0 | elk        | dog        ||  1 | pig        | quetzal    |

Output markdown with a tabulate option.

>>>print(df.to_markdown(tablefmt="grid"))+----+------------+------------+|    | animal_1   | animal_2   |+====+============+============+|  0 | elk        | dog        |+----+------------+------------+|  1 | pig        | quetzal    |+----+------------+------------+

[8]ページ先頭

©2009-2025 Movatter.jp