-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Rephrased doc for Series.asof. Added examples #21034
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
Conversation
pandas/core/generic.py
Outdated
-------- | ||
Take all columns into consideration | ||
|
||
>>> data = u'''dt,a,b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably best to construct this directly, rather than using read_csv. Can you do
df = pd.DataFrame({'a': [...], 'b': [...], index=pd.DatetimeIndex([...])
instead? Also, these floating point values are a bit hard to understand when just glancing. Could you change to integers instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We recently added a docstring guide http://pandas-docs.github.io/pandas-docs-travis/contributing_docstring.html
Can you validate that your changes pass this guide?
Codecov Report
@@ Coverage Diff @@
## master #21034 +/- ##
==========================================
- Coverage 92.23% 92.23% -0.01%
==========================================
Files 161 161
Lines 51187 51197 +10
==========================================
+ Hits 47211 47220 +9
- Misses 3976 3977 +1
Continue to review full report at Codecov.
|
Hello @dragosthealex! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on May 14, 2018 at 20:44 Hours UTC |
Used code from #20652 as example, to illustrate different behaviours.
@TomAugspurger Yes, the validation passes |
pandas/core/generic.py
Outdated
@@ -6065,19 +6071,43 @@ def asof(self, where, subset=None): | |||
|
|||
Returns | |||
------- | |||
where is scalar | |||
`where` is scalar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be formatted as
possible types
case 1
case 2
so somehting like
scalar, Series, or DataFrame
* scalar : when `self` is a Series and `where` is a scalar
* Series: when `self` is a Series and `where` is an array-like, or when `self` is a DataFrame and `where` is a scalar
* DataFrame : when `self` is a DataFrame and `where` is an array-like
pandas/core/generic.py
Outdated
|
||
where is Index: same shape object as input | ||
`where` is :class:`pandas.Index`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand this. Is an Index for where
treated differently than other inputes?
|
||
Examples | ||
-------- | ||
Take all columns into consideration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add additional examples for
- Series w/ scalar where
- Series w/ array-like where
- DataFrame w/ scalar where
can you update for comments |
closing as stale. if you'd like to continue pls ping. |
@datapythonista this looks close. |
Pushed a quick update. Probably good to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed couple of additional formatting fixes, merging on green
thanks @dragosthealex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@datapythonista I was fixing some doc warnings in #23636, and came across those ones.
In the PR I simply removed all quotes on "NaN" (as that also avoids the problem with "NaNs"), but can certainly discuss further.
@@ -6495,40 +6495,98 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False, | |||
|
|||
def asof(self, where, subset=None): | |||
""" | |||
The last row without any NaN is taken (or the last row without | |||
NaN considering only the subset of columns in the case of a DataFrame) | |||
Return the last row(s) without any `NaN`s before `where`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like `NaN`s
fails in sphinx, we can only use `
on things that are quoted completely, without trailing 's' or so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further, I am not fully sure we should quote NaN. It is not a pandas function name or keyword argument or so. I would rather say it is "code"-like, but then we should actually use the proper name like np.nan
. Therefore, maybe a compromise to simply not quote?
if not None use these columns for NaN propagation | ||
where : date or array-like of dates | ||
Date(s) before which the last row(s) are returned. | ||
subset : str or array-like of str, default `None` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in general we don't quote on the parameter type line?
Yes, those are good points I wanted to discuss at some point. This is something I fixed in the past, as the rendering in sphinx was broken:
For what I know, single backticks should be used for argument names, variables, functions, methods, classes... So, In the type, we don't usually use backticks (but I've seen some cases where we do):
I don't have a preference either, but we should start to be consistent. May be we should create an issue, have some discussion, and then start enforcing it? Not sure how difficult can be to add validation for this in |
Used code from #20652 as example, to illustrate different behaviours.
git diff upstream/master -u -- "*.py" | flake8 --diff