Skip to content

DOC: Update the pandas.core.window.x.sum docstring #20272

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 6 commits into from
Mar 14, 2018
Merged
Changes from 2 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
53 changes: 49 additions & 4 deletions pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,52 @@ def aggregate(self, arg, *args, **kwargs):
agg = aggregate

_shared_docs['sum'] = dedent("""
%(name)s sum""")
Calculate %(name)s sum of given DataFrame or Series.

Parameters
----------
*args
Under Review.
**kwargs
Under Review.

Returns
-------
Series or DataFrame
Like-indexed object containing the result of function application
Copy link
Member

Choose a reason for hiding this comment

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

Period at end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


See Also
--------
Series.%(name)s : Calling object with Series data
DataFrame.%(name)s : Calling object with DataFrame data
Series.sum : Equivalent method for Series
Copy link
Member

Choose a reason for hiding this comment

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

Whitespace seems off on this line and below - are there more than one before the ":"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup. Deleted.

DataFrame.sum : Equivalent method for DataFrame

Examples
--------
>>> s = pd.Series([1, 2, 3, 4, 5])
>>> s.rolling(3).sum()
0 NaN
1 NaN
2 6.0
3 9.0
4 12.0
dtype: float64
>>> s.expanding(3).sum()
Copy link
Contributor

Choose a reason for hiding this comment

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

blank line between cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added one line for each case.

0 NaN
1 NaN
2 6.0
3 10.0
4 15.0
dtype: float64
>>> s.rolling(3, center=True).sum()
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 this is a great example, but maybe add one line or comment for what to expect with center=True

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I have added one line of explanation stating that how this argument helps.

0 NaN
1 6.0
2 9.0
3 12.0
4 NaN
dtype: float64
""")

_shared_docs['mean'] = dedent("""
%(name)s mean""")
Expand Down Expand Up @@ -639,7 +684,7 @@ def aggregate(self, arg, *args, **kwargs):
agg = aggregate

@Substitution(name='window')
@Appender(_doc_template)
# @Appender(_doc_template)
Copy link
Contributor

Choose a reason for hiding this comment

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

don't comment, simply remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your comments are valuable and I have deleted necessary code.

@Appender(_shared_docs['sum'])
def sum(self, *args, **kwargs):
nv.validate_window_func('sum', args, kwargs)
Expand Down Expand Up @@ -1213,7 +1258,7 @@ def apply(self, func, args=(), kwargs={}):
return super(Rolling, self).apply(func, args=args, kwargs=kwargs)

@Substitution(name='rolling')
@Appender(_doc_template)
# @Appender(_doc_template)
@Appender(_shared_docs['sum'])
def sum(self, *args, **kwargs):
nv.validate_rolling_func('sum', args, kwargs)
Expand Down Expand Up @@ -1452,7 +1497,7 @@ def apply(self, func, args=(), kwargs={}):
return super(Expanding, self).apply(func, args=args, kwargs=kwargs)

@Substitution(name='expanding')
@Appender(_doc_template)
# @Appender(_doc_template)
@Appender(_shared_docs['sum'])
def sum(self, *args, **kwargs):
nv.validate_expanding_func('sum', args, kwargs)
Expand Down