From a64aa7eb3198798e37ee7e59a825b3b33ccac4ed Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Sat, 4 May 2024 16:25:47 +0530 Subject: [PATCH 1/2] DOC: add SA01 for pandas.DataFrame.to_markdown --- pandas/core/frame.py | 67 +++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 96943eb71c7bd..e6223d1f7bf7d 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2749,11 +2749,55 @@ def to_markdown( **kwargs, ) -> str | None: ... - @doc( - Series.to_markdown, - klass=_shared_doc_kwargs["klass"], - storage_options=_shared_docs["storage_options"], - examples="""Examples + def to_markdown( + self, + buf: FilePath | WriteBuffer[str] | None = None, + *, + mode: str = "wt", + index: bool = True, + storage_options: StorageOptions | None = None, + **kwargs, + ) -> str | None: + """ + Print DataFrame in Markdown-friendly format. + + Parameters + ---------- + buf : str, Path or StringIO-like, optional, default None + Buffer to write to. If None, the output is returned as a string. + mode : str, optional + Mode in which file is opened, "wt" by default. + index : bool, optional, default True + Add index (row) labels. + + storage_options : dict, 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 pairs + are forwarded to ``urllib.request.Request`` as header options. For other + URLs (e.g. starting with "s3://", and "gcs://") the key-value pairs are + forwarded to ``fsspec.open``. Please see ``fsspec`` and ``urllib`` for more + details, and for more examples on storage options refer `here + `_. + + **kwargs + These parameters will be passed to `tabulate `_. + + Returns + ------- + str + DataFrame in Markdown-friendly format. + + See Also + -------- + DataFrame.to_html : Render DataFrame to HTML-formatted table. + DataFrame.to_latex : Render DataFrame to LaTeX-formatted table. + + Notes + ----- + Requires the `tabulate `_ package. + + Examples -------- >>> df = pd.DataFrame( ... data={"animal_1": ["elk", "pig"], "animal_2": ["dog", "quetzal"]} @@ -2773,17 +2817,8 @@ def to_markdown( | 0 | elk | dog | +----+------------+------------+ | 1 | pig | quetzal | - +----+------------+------------+""", - ) - def to_markdown( - self, - buf: FilePath | WriteBuffer[str] | None = None, - *, - mode: str = "wt", - index: bool = True, - storage_options: StorageOptions | None = None, - **kwargs, - ) -> str | None: + +----+------------+------------+ + """ if "showindex" in kwargs: raise ValueError("Pass 'index' instead of 'showindex") From 7f3578a0a7b7467b7d024bf75627c70cb658afce Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Sat, 4 May 2024 16:26:07 +0530 Subject: [PATCH 2/2] DOC: remove SA01 for pandas.DataFrame.to_markdown --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 936e3664cfe93..f7a6676637ca2 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -78,7 +78,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.DataFrame.std PR01,RT03,SA01" \ -i "pandas.DataFrame.sum RT03" \ -i "pandas.DataFrame.swaplevel SA01" \ - -i "pandas.DataFrame.to_markdown SA01" \ -i "pandas.DataFrame.var PR01,RT03,SA01" \ -i "pandas.Grouper PR02" \ -i "pandas.Index PR07" \