Skip to content

Commit 22eb39f

Browse files
DOC: Enforce Numpy Docstring Validation for pandas.DataFrame.to_markdown (#58567)
* DOC: add SA01 for pandas.DataFrame.to_markdown * DOC: remove SA01 for pandas.DataFrame.to_markdown
1 parent 51c547b commit 22eb39f

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7878
-i "pandas.DataFrame.std PR01,RT03,SA01" \
7979
-i "pandas.DataFrame.sum RT03" \
8080
-i "pandas.DataFrame.swaplevel SA01" \
81-
-i "pandas.DataFrame.to_markdown SA01" \
8281
-i "pandas.Grouper PR02" \
8382
-i "pandas.Index PR07" \
8483
-i "pandas.Index.join PR07,RT03,SA01" \

pandas/core/frame.py

+51-16
Original file line numberDiff line numberDiff line change
@@ -2749,11 +2749,55 @@ def to_markdown(
27492749
**kwargs,
27502750
) -> str | None: ...
27512751

2752-
@doc(
2753-
Series.to_markdown,
2754-
klass=_shared_doc_kwargs["klass"],
2755-
storage_options=_shared_docs["storage_options"],
2756-
examples="""Examples
2752+
def to_markdown(
2753+
self,
2754+
buf: FilePath | WriteBuffer[str] | None = None,
2755+
*,
2756+
mode: str = "wt",
2757+
index: bool = True,
2758+
storage_options: StorageOptions | None = None,
2759+
**kwargs,
2760+
) -> str | None:
2761+
"""
2762+
Print DataFrame in Markdown-friendly format.
2763+
2764+
Parameters
2765+
----------
2766+
buf : str, Path or StringIO-like, optional, default None
2767+
Buffer to write to. If None, the output is returned as a string.
2768+
mode : str, optional
2769+
Mode in which file is opened, "wt" by default.
2770+
index : bool, optional, default True
2771+
Add index (row) labels.
2772+
2773+
storage_options : dict, optional
2774+
Extra options that make sense for a particular storage connection, e.g.
2775+
host, port, username, password, etc. For HTTP(S) URLs the key-value pairs
2776+
are forwarded to ``urllib.request.Request`` as header options. For other
2777+
URLs (e.g. starting with "s3://", and "gcs://") the key-value pairs are
2778+
forwarded to ``fsspec.open``. Please see ``fsspec`` and ``urllib`` for more
2779+
details, and for more examples on storage options refer `here
2780+
<https://pandas.pydata.org/docs/user_guide/io.html?
2781+
highlight=storage_options#reading-writing-remote-files>`_.
2782+
2783+
**kwargs
2784+
These parameters will be passed to `tabulate <https://pypi.org/project/tabulate>`_.
2785+
2786+
Returns
2787+
-------
2788+
str
2789+
DataFrame in Markdown-friendly format.
2790+
2791+
See Also
2792+
--------
2793+
DataFrame.to_html : Render DataFrame to HTML-formatted table.
2794+
DataFrame.to_latex : Render DataFrame to LaTeX-formatted table.
2795+
2796+
Notes
2797+
-----
2798+
Requires the `tabulate <https://pypi.org/project/tabulate>`_ package.
2799+
2800+
Examples
27572801
--------
27582802
>>> df = pd.DataFrame(
27592803
... data={"animal_1": ["elk", "pig"], "animal_2": ["dog", "quetzal"]}
@@ -2773,17 +2817,8 @@ def to_markdown(
27732817
| 0 | elk | dog |
27742818
+----+------------+------------+
27752819
| 1 | pig | quetzal |
2776-
+----+------------+------------+""",
2777-
)
2778-
def to_markdown(
2779-
self,
2780-
buf: FilePath | WriteBuffer[str] | None = None,
2781-
*,
2782-
mode: str = "wt",
2783-
index: bool = True,
2784-
storage_options: StorageOptions | None = None,
2785-
**kwargs,
2786-
) -> str | None:
2820+
+----+------------+------------+
2821+
"""
27872822
if "showindex" in kwargs:
27882823
raise ValueError("Pass 'index' instead of 'showindex")
27892824

0 commit comments

Comments
 (0)