Skip to content

DOC: Fixing EX01 - Added examples #54004

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 1 commit into from
Jul 6, 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
6 changes: 0 additions & 6 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas_object \
pandas.api.interchange.from_dataframe \
pandas.DatetimeIndex.snap \
pandas.core.window.ewm.ExponentialMovingWindow.mean \
pandas.core.window.ewm.ExponentialMovingWindow.sum \
pandas.core.window.ewm.ExponentialMovingWindow.std \
pandas.core.window.ewm.ExponentialMovingWindow.var \
pandas.core.window.ewm.ExponentialMovingWindow.corr \
pandas.core.window.ewm.ExponentialMovingWindow.cov \
pandas.api.indexers.BaseIndexer \
pandas.api.indexers.VariableOffsetWindowIndexer \
pandas.io.formats.style.Styler \
Expand Down
102 changes: 88 additions & 14 deletions pandas/core/window/ewm.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,19 @@ def aggregate(self, func, *args, **kwargs):
create_section_header("See Also"),
template_see_also,
create_section_header("Notes"),
numba_notes.replace("\n", "", 1),
numba_notes,
create_section_header("Examples"),
dedent(
"""\
>>> ser = pd.Series([1, 2, 3, 4])
>>> ser.ewm(alpha=.2).mean()
Copy link
Member

Choose a reason for hiding this comment

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

nice! I don't know how hard it is, but for a simple example like this one, would it be feasible to show how the result is calculated? like, to match it with just simple numpy operations?

0 1.000000
1 1.555556
2 2.147541
3 2.775068
dtype: float64
"""
),
window_method="ewm",
aggregation_description="(exponential weighted moment) mean",
agg_method="mean",
Expand Down Expand Up @@ -554,7 +566,19 @@ def mean(
create_section_header("See Also"),
template_see_also,
create_section_header("Notes"),
numba_notes.replace("\n", "", 1),
numba_notes,
create_section_header("Examples"),
dedent(
"""\
>>> ser = pd.Series([1, 2, 3, 4])
>>> ser.ewm(alpha=.2).sum()
0 1.000
1 2.800
2 5.240
3 8.192
dtype: float64
"""
),
window_method="ewm",
aggregation_description="(exponential weighted moment) sum",
agg_method="sum",
Expand Down Expand Up @@ -602,16 +626,28 @@ def sum(
template_header,
create_section_header("Parameters"),
dedent(
"""
"""\
bias : bool, default False
Use a standard estimation bias correction.
"""
).replace("\n", "", 1),
),
kwargs_numeric_only,
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([1, 2, 3, 4])
>>> ser.ewm(alpha=.2).std()
0 NaN
1 0.707107
2 0.995893
3 1.277320
dtype: float64
"""
),
window_method="ewm",
aggregation_description="(exponential weighted moment) standard deviation",
agg_method="std",
Expand All @@ -632,16 +668,28 @@ def std(self, bias: bool = False, numeric_only: bool = False):
template_header,
create_section_header("Parameters"),
dedent(
"""
"""\
bias : bool, default False
Use a standard estimation bias correction.
"""
).replace("\n", "", 1),
),
kwargs_numeric_only,
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([1, 2, 3, 4])
>>> ser.ewm(alpha=.2).var()
0 NaN
1 0.500000
2 0.991803
3 1.631547
dtype: float64
"""
),
window_method="ewm",
aggregation_description="(exponential weighted moment) variance",
agg_method="var",
Expand All @@ -665,7 +713,7 @@ def var_func(values, begin, end, min_periods):
template_header,
create_section_header("Parameters"),
dedent(
"""
"""\
other : Series or DataFrame , optional
If not supplied then will default to self and produce pairwise
output.
Expand All @@ -679,12 +727,25 @@ def var_func(values, begin, end, min_periods):
bias : bool, default False
Use a standard estimation bias correction.
"""
).replace("\n", "", 1),
),
kwargs_numeric_only,
create_section_header("Returns"),
template_returns,
create_section_header("See Also"),
template_see_also[:-1],
template_see_also,
create_section_header("Examples"),
dedent(
"""\
>>> ser1 = pd.Series([1, 2, 3, 4])
>>> ser2 = pd.Series([10, 11, 13, 16])
>>> ser1.ewm(alpha=.2).cov(ser2)
0 NaN
1 0.500000
2 1.524590
3 3.408836
dtype: float64
"""
),
window_method="ewm",
aggregation_description="(exponential weighted moment) sample covariance",
agg_method="cov",
Expand Down Expand Up @@ -739,7 +800,7 @@ def cov_func(x, y):
template_header,
create_section_header("Parameters"),
dedent(
"""
"""\
other : Series or DataFrame, optional
If not supplied then will default to self and produce pairwise
output.
Expand All @@ -751,12 +812,25 @@ def cov_func(x, y):
inputs. In the case of missing elements, only complete pairwise
observations will be used.
"""
).replace("\n", "", 1),
),
kwargs_numeric_only,
create_section_header("Returns"),
template_returns,
create_section_header("See Also"),
template_see_also[:-1],
template_see_also,
create_section_header("Examples"),
dedent(
"""\
>>> ser1 = pd.Series([1, 2, 3, 4])
>>> ser2 = pd.Series([10, 11, 13, 16])
>>> ser1.ewm(alpha=.2).corr(ser2)
0 NaN
1 1.000000
2 0.982821
3 0.977802
dtype: float64
"""
),
window_method="ewm",
aggregation_description="(exponential weighted moment) sample correlation",
agg_method="corr",
Expand Down