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 1 commit
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 @@ -114,10 +114,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.core.window.rolling.Rolling.cov \
pandas.core.window.rolling.Rolling.skew \
pandas.core.window.rolling.Rolling.apply \
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.expanding.Expanding.count \
pandas.core.window.expanding.Expanding.sum \
pandas.core.window.expanding.Expanding.mean \
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])

In order to get an instance of 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 `Sci-py` gaussian window we need to provide the parameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just write "SciPy"

also, gaussian => Gaussian

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

M and std. The parameter M corresponds to 2 in our example.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add backticks to the variable names here? Like

`M` and `std`

The general rule (which admittedly isn't followed very consistently) from the numpy guide is to use single backticks for variable names, and double backticks otherwise

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot about that.

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
"""
).replace("\n", "", 1),
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])

In order to get an instance of 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 `Sci-py` 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
"""
).replace("\n", "", 1),
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])

In order to get an instance of 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 `Sci-py` 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
"""
).replace("\n", "", 1),
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])

In order to get an instance of pandas.core.window.rolling.Window we need
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this link work? I think you may need to write :class:pandas.core.window.rolling.Window, or :class:~pandas.core.window.rolling.Window to hide part of the path

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

to pass the parameter `win_type`.

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

In order to use the `Sci-py` 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
"""
).replace("\n", "", 1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as in the other PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch... I just saw this one! - I'll change it.

window_method="rolling",
aggregation_description="weighted window standard deviation",
agg_method="std",
Expand Down