Skip to content

Commit 4dabefe

Browse files
committed
fixed doc strings
1 parent c96dce0 commit 4dabefe

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

pandas/core/frame.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,8 +2076,10 @@ def to_feather(self, path) -> None:
20762076

20772077
to_feather(self, path)
20782078

2079-
@Appender(
2080-
"""
2079+
@doc(
2080+
Series.to_markdown,
2081+
klass=_shared_doc_kwargs["klass"],
2082+
examples="""
20812083
Examples
20822084
--------
20832085
>>> df = pd.DataFrame(
@@ -2088,10 +2090,8 @@ def to_feather(self, path) -> None:
20882090
|---:|:-----------|:-----------|
20892091
| 0 | elk | dog |
20902092
| 1 | pig | quetzal |
2091-
"""
2093+
""",
20922094
)
2093-
@Substitution(klass="DataFrame")
2094-
@Appender(_shared_docs["to_markdown"])
20952095
def to_markdown(
20962096
self, buf: Optional[IO[str]] = None, mode: Optional[str] = None, **kwargs
20972097
) -> Optional[str]:

pandas/core/series.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,21 @@ def to_string(
14241424
with open(buf, "w") as f:
14251425
f.write(result)
14261426

1427-
@doc(klass=_shared_doc_kwargs["klass"])
1427+
@doc(
1428+
klass=_shared_doc_kwargs["klass"],
1429+
examples="""
1430+
Examples
1431+
--------
1432+
>>> s = pd.Series(["elk", "pig", "dog", "quetzal"], name="animal")
1433+
>>> print(s.to_markdown())
1434+
| | animal |
1435+
|---:|:---------|
1436+
| 0 | elk |
1437+
| 1 | pig |
1438+
| 2 | dog |
1439+
| 3 | quetzal |
1440+
""",
1441+
)
14281442
def to_markdown(
14291443
self, buf: Optional[IO[str]] = None, mode: Optional[str] = None, **kwargs
14301444
) -> Optional[str]:
@@ -1447,16 +1461,7 @@ def to_markdown(
14471461
str
14481462
{klass} in Markdown-friendly format.
14491463
1450-
Examples
1451-
--------
1452-
>>> s = pd.Series(["elk", "pig", "dog", "quetzal"], name="animal")
1453-
>>> print(s.to_markdown())
1454-
| | animal |
1455-
|---:|:---------|
1456-
| 0 | elk |
1457-
| 1 | pig |
1458-
| 2 | dog |
1459-
| 3 | quetzal |
1464+
{examples}
14601465
"""
14611466
return self.to_frame().to_markdown(buf, mode, **kwargs)
14621467

0 commit comments

Comments
 (0)