Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cln 31942/replace appender with doc 6 #34876

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3951,8 +3951,7 @@ def align(
def set_axis(self, labels, axis: Axis = 0, inplace: bool = False):
return super().set_axis(labels, axis=axis, inplace=inplace)

@Substitution(**_shared_doc_kwargs)
@Appender(NDFrame.reindex.__doc__)
@doc(NDFrame.reindex, **_shared_doc_kwargs)
@rewrite_axis_style_signature(
"labels",
[
Expand Down
12 changes: 3 additions & 9 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4213,12 +4213,6 @@ def sort_values(
"""
raise AbstractMethodError(self)

@doc(
klass=_shared_doc_kwargs["klass"],
axes=_shared_doc_kwargs["axes"],
optional_labels="",
optional_axis="",
)
def reindex(self: FrameOrSeries, *args, **kwargs) -> FrameOrSeries:
"""
Conform {klass} to new index with optional filling logic.
Expand Down Expand Up @@ -4289,8 +4283,8 @@ def reindex(self: FrameOrSeries, *args, **kwargs) -> FrameOrSeries:
Create a dataframe with some fictional data.

>>> index = ['Firefox', 'Chrome', 'Safari', 'IE10', 'Konqueror']
>>> df = pd.DataFrame({{'http_status': [200, 200, 404, 404, 301],
... 'response_time': [0.04, 0.02, 0.07, 0.08, 1.0]}},
>>> df = pd.DataFrame(dict(http_status=[200, 200, 404, 404, 301],
... response_time=[0.04, 0.02, 0.07, 0.08, 1.0]),
... index=index)
>>> df
http_status response_time
Expand Down Expand Up @@ -4361,7 +4355,7 @@ def reindex(self: FrameOrSeries, *args, **kwargs) -> FrameOrSeries:
of dates).

>>> date_index = pd.date_range('1/1/2010', periods=6, freq='D')
>>> df2 = pd.DataFrame({{"prices": [100, 101, np.nan, 100, 89, 88]}},
>>> df2 = pd.DataFrame(dict(prices=[100, 101, np.nan, 100, 89, 88]),
... index=date_index)
>>> df2
prices
Expand Down
45 changes: 17 additions & 28 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,8 +1408,7 @@ def to_string(
@doc(
klass=_shared_doc_kwargs["klass"],
examples=dedent(
"""
Examples
"""Examples
--------
>>> s = pd.Series(["elk", "pig", "dog", "quetzal"], name="animal")
>>> print(s.to_markdown())
Expand All @@ -1419,6 +1418,21 @@ def to_string(
| 1 | pig |
| 2 | dog |
| 3 | quetzal |

Output markdown with a tabulate option.

>>> print(s.to_markdown(tablefmt="grid"))
+----+----------+
| | animal |
+====+==========+
| 0 | elk |
+----+----------+
| 1 | pig |
+----+----------+
| 2 | dog |
+----+----------+
| 3 | quetzal |
+----+----------+
"""
),
)
Expand All @@ -1444,32 +1458,7 @@ def to_markdown(
-------
str
{klass} in Markdown-friendly format.

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

Output markdown with a tabulate option.

>>> print(s.to_markdown(tablefmt="grid"))
+----+----------+
| | animal |
+====+==========+
| 0 | elk |
+----+----------+
| 1 | pig |
+----+----------+
| 2 | dog |
+----+----------+
| 3 | quetzal |
+----+----------+
{examples}
"""
return self.to_frame().to_markdown(buf, mode, **kwargs)

Expand Down