pandas.Series.to_markdown#

Series.to_markdown(buf=None, mode='wt', index=True, storage_options=None, **kwargs)[源代码]#

以 Markdown 友好的格式打印 Series。

Parameters:
bufstr, Path 或 StringIO-like,可选,默认为 None

写入的缓冲区。如果为 None,则输出作为字符串返回。

modebool, default False

文件打开模式,默认为 “wt”。

indexbool,可选,默认为 True

添加索引(行)标签。

storage_optionsdict, 可选

适用于特定存储连接的额外选项,例如主机、端口、用户名、密码等。对于 HTTP(S) URL,键值对将作为标头选项转发给 urllib.request.Request。对于其他 URL(例如,以 “s3://”, 和 “gcs://” 开头的 URL),键值对将转发给 fsspec.open。更多详情请参阅 fsspecurllib,有关存储选项的更多示例,请参阅 here

**kwargs

这些参数将传递给 tabulate

Returns:
str

Markdown 兼容格式的 Series。

Notes

需要 tabulate 包。

Examples

>>> s = pd.Series(["elk", "pig", "dog", "quetzal"], name="animal")
>>> print(s.to_markdown())
|    | animal   |
|---:|:---------|
|  0 | elk      |
|  1 | pig      |
|  2 | dog      |
|  3 | quetzal  |

输出带有 tabulate 选项的 markdown。

>>> print(s.to_markdown(tablefmt="grid"))
+----+----------+
|    | animal   |
+====+==========+
|  0 | elk      |
+----+----------+
|  1 | pig      |
+----+----------+
|  2 | dog      |
+----+----------+
|  3 | quetzal  |
+----+----------+