Skip to content

DOC: Fixing EX01 - Added examples #53982

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

Merged
merged 7 commits into from
Jul 5, 2023
Merged
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
4 changes: 0 additions & 4 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas_object \
pandas.api.interchange.from_dataframe \
pandas.DatetimeIndex.snap \
pandas.core.window.rolling.Window.mean \
pandas.core.window.rolling.Window.sum \
pandas.core.window.rolling.Window.var \
pandas.core.window.rolling.Window.std \
pandas.core.window.ewm.ExponentialMovingWindow.mean \
pandas.core.window.ewm.ExponentialMovingWindow.sum \
pandas.core.window.ewm.ExponentialMovingWindow.std \
Expand Down
105 changes: 101 additions & 4 deletions pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,32 @@ def aggregate(self, func, *args, **kwargs):
create_section_header("Returns"),
template_returns,
create_section_header("See Also"),
template_see_also[:-1],
template_see_also,
create_section_header("Examples"),
dedent(
"""\
>>> ser = pd.Series([0, 1, 5, 2, 8])

To get an instance of :class:`~pandas.core.window.rolling.Window` we need
to pass the parameter `win_type`.

>>> type(ser.rolling(2, win_type='gaussian'))
<class 'pandas.core.window.rolling.Window'>

In order to use the `SciPy` Gaussian window we need to provide the parameters
`M` and `std`. The parameter `M` corresponds to 2 in our example.
We pass the second parameter `std` as a parameter of the following method
(`sum` in this case):

>>> ser.rolling(2, win_type='gaussian').sum(std=3)
0 NaN
1 0.986207
2 5.917243
3 6.903450
4 9.862071
dtype: float64
"""
),
window_method="rolling",
aggregation_description="weighted window sum",
agg_method="sum",
Expand All @@ -1295,7 +1320,31 @@ def sum(self, numeric_only: bool = False, **kwargs):
create_section_header("Returns"),
template_returns,
create_section_header("See Also"),
template_see_also[:-1],
template_see_also,
create_section_header("Examples"),
dedent(
"""\
>>> ser = pd.Series([0, 1, 5, 2, 8])

To get an instance of :class:`~pandas.core.window.rolling.Window` we need
to pass the parameter `win_type`.

>>> type(ser.rolling(2, win_type='gaussian'))
<class 'pandas.core.window.rolling.Window'>

In order to use the `SciPy` Gaussian window we need to provide the parameters
`M` and `std`. The parameter `M` corresponds to 2 in our example.
We pass the second parameter `std` as a parameter of the following method:

>>> ser.rolling(2, win_type='gaussian').mean(std=3)
0 NaN
1 0.5
2 3.0
3 3.5
4 5.0
dtype: float64
"""
),
window_method="rolling",
aggregation_description="weighted window mean",
agg_method="mean",
Expand All @@ -1320,7 +1369,31 @@ def mean(self, numeric_only: bool = False, **kwargs):
create_section_header("Returns"),
template_returns,
create_section_header("See Also"),
template_see_also[:-1],
template_see_also,
create_section_header("Examples"),
dedent(
"""\
>>> ser = pd.Series([0, 1, 5, 2, 8])

To get an instance of :class:`~pandas.core.window.rolling.Window` we need
to pass the parameter `win_type`.

>>> type(ser.rolling(2, win_type='gaussian'))
<class 'pandas.core.window.rolling.Window'>

In order to use the `SciPy` Gaussian window we need to provide the parameters
`M` and `std`. The parameter `M` corresponds to 2 in our example.
We pass the second parameter `std` as a parameter of the following method:

>>> ser.rolling(2, win_type='gaussian').var(std=3)
0 NaN
1 0.5
2 8.0
3 4.5
4 18.0
dtype: float64
"""
),
window_method="rolling",
aggregation_description="weighted window variance",
agg_method="var",
Expand All @@ -1338,7 +1411,31 @@ def var(self, ddof: int = 1, numeric_only: bool = False, **kwargs):
create_section_header("Returns"),
template_returns,
create_section_header("See Also"),
template_see_also[:-1],
template_see_also,
create_section_header("Examples"),
dedent(
"""\
>>> ser = pd.Series([0, 1, 5, 2, 8])

To get an instance of :class:`~pandas.core.window.rolling.Window` we need
to pass the parameter `win_type`.

>>> type(ser.rolling(2, win_type='gaussian'))
<class 'pandas.core.window.rolling.Window'>

In order to use the `SciPy` Gaussian window we need to provide the parameters
`M` and `std`. The parameter `M` corresponds to 2 in our example.
We pass the second parameter `std` as a parameter of the following method:

>>> ser.rolling(2, win_type='gaussian').std(std=3)
0 NaN
1 0.707107
2 2.828427
3 2.121320
4 4.242641
dtype: float64
"""
),
window_method="rolling",
aggregation_description="weighted window standard deviation",
agg_method="std",
Expand Down