-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Series as of docstring #20226
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
Series as of docstring #20226
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5401,40 +5401,59 @@ 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) | ||
|
||
.. versionadded:: 0.19.0 For DataFrame | ||
|
||
If there is no good value, NaN is returned for a Series | ||
a Series of NaN values for a DataFrame | ||
|
||
Take the last row without any NaN. | ||
|
||
Or the last row without NaN considering only the subset of columns in the case of a DataFrame. | ||
If there is no matched value, NaN is returned for a Series a Series of NaN values for a DataFrame. | ||
|
||
.. versionadded:: 0.19.0 For DataFrame. | ||
|
||
Parameters | ||
---------- | ||
where : date or array of dates | ||
subset : string or list of strings, default None | ||
if not None use these columns for NaN propagation | ||
where : datetime | ||
Date or array of dates. | ||
subset : str | ||
String or list of strings, default None if not None use these columns for NaN propagation. | ||
|
||
Notes | ||
----- | ||
Dates are assumed to be sorted | ||
Raises if this is not the case | ||
Dates are assumed to be sorted. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you make a Raises section and add ValueError there (if dates are not sorted) |
||
Raises if this is not the case. | ||
|
||
Returns | ||
------- | ||
where is scalar | ||
|
||
- value or NaN if input is Series | ||
- Series if input is DataFrame | ||
- value or NaN if input is Series. | ||
- Series if input is DataFrame. | ||
|
||
where is Index: same shape object as input | ||
where is Index: same shape object as input. | ||
|
||
See Also | ||
-------- | ||
merge_asof | ||
|
||
""" | ||
merge_asof : Perform an asof merge. This is similar to a left-join except that we match on nearest key rather than equal keys. | ||
|
||
Examples | ||
-------- | ||
>>> import pandas as pd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't need pandas import |
||
>>> from datetime import datetime | ||
|
||
>>> names = ['curupira', 'saci', 'boitata', 'tupa', float('NaN'), 'cuca'] | ||
>>> dates = [datetime.strptime('20130101', '%Y%m%d'), | ||
... datetime.strptime('20140101', '%Y%m%d'), | ||
... datetime.strptime('20140101', '%Y%m%d'), | ||
... datetime.strptime('20150101', '%Y%m%d'), | ||
... datetime.strptime('20150101', '%Y%m%d'), | ||
... datetime.strptime('20160101', '%Y%m%d')] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can generate some dates with |
||
>>> mySeries = pd.Series(data=names, index=dates) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can call the series |
||
>>> mySeries.asof(datetime.strptime('20150102', '%Y%m%d')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use |
||
'tupa' | ||
>>> mySeries.asof(datetime.strptime('20190201', '%Y%m%d')) | ||
'cuca' | ||
>>> mySeries.asof(datetime.strptime('20120201', '%Y%m%d')) | ||
nan | ||
""" | ||
|
||
if isinstance(where, compat.string_types): | ||
from pandas import to_datetime | ||
where = to_datetime(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.
subset: str or list of strings
if not None, use the columns for NaN propagation.