-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: add Raises, Examples and See Also sections to methods at_time/between_time/first/last #20725
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
The failures are in |
pandas/core/generic.py
Outdated
@@ -6703,13 +6703,39 @@ def at_time(self, time, asof=False): | |||
""" | |||
Select values at particular time of day (e.g. 9:30AM). | |||
|
|||
Notes | |||
----- | |||
For this method to work, the index must to be a :class:`DateTimeIndex` |
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.
The "T" should be lowercase in DatetimeIndex
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.
Likewise for the other "Notes" sections
pandas/core/generic.py
Outdated
-------- | ||
between_time : Select values between particular times of the day | ||
first : select initial periods of time series based on a date offset | ||
last: select final periods of time series based on a date offset |
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.
The capitalization is inconsistent at the beginning of the descriptions: "S" vs "s" in select.
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.
Likewise in the other "See Also" sections
bec54c3
to
a101788
Compare
Codecov Report
@@ Coverage Diff @@
## master #20725 +/- ##
==========================================
+ Coverage 91.81% 91.82% +0.01%
==========================================
Files 153 153
Lines 49481 49483 +2
==========================================
+ Hits 45430 45437 +7
+ Misses 4051 4046 -5
Continue to review full report at Codecov.
|
Comments from @jschendel have been addressed, thanks for the review. |
81f6b51
to
2b063e9
Compare
@@ -6703,13 +6703,40 @@ def at_time(self, time, asof=False): | |||
""" | |||
Select values at particular time of day (e.g. 9:30AM). | |||
|
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.
put this in a Raises section instead
pandas/core/generic.py
Outdated
2018-04-09 12:00:00 2 | ||
2018-04-10 00:00:00 3 | ||
2018-04-10 12:00:00 4 | ||
>>> ts.at_time('12:00') |
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.
blank line between cases
pandas/core/generic.py
Outdated
By setting ``start_time`` to be later than ``end_time``, | ||
you can get the times that are *not* between the two times. | ||
|
||
Notes |
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.
same as above
pandas/core/indexes/datetimes.py
Outdated
datetime.time or string in appropriate format ("%H:%M", "%H%M", | ||
"%I:%M%p", "%I%M%p", "%H:%M:%S", "%H%M%S", "%I:%M:%S%p", | ||
"%I%M%S%p"). | ||
If strings, then ``tseries.tools.to_time`` is used to convert to |
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 last sentence is refering to an internal method, remove it
pandas/core/indexes/datetimes.py
Outdated
|
||
Returns | ||
------- | ||
values_at_time : TimeSeries | ||
values_at_time : array |
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.
boolean array
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.
Actually it returns an array of integers (i.e. integer location)
pandas/core/indexes/datetimes.py
Outdated
|
||
Parameters | ||
---------- | ||
start_time, end_time : datetime.time, str | ||
datetime.time or string in appropriate format ("%H:%M", "%H%M", | ||
"%I:%M%p", "%I%M%p", "%H:%M:%S", "%H%M%S", "%I:%M:%S%p", | ||
"%I%M%S%p") | ||
"%I%M%S%p"). | ||
If strings, then ``tseries.tools.to_time`` is used to convert to |
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.
same
are these functions in api.rst? |
Yes for all of them. |
2b063e9
to
9472196
Compare
Comments addessed. |
9472196
to
c470fdd
Compare
pandas/core/generic.py
Outdated
@@ -6703,13 +6703,42 @@ def at_time(self, time, asof=False): | |||
""" | |||
Select values at particular time of day (e.g. 9:30AM). | |||
|
|||
Raises | |||
----- | |||
AttributeError |
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.
really? this should be something else, prob a TypeError
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.
Changed to TypeError, and whatsnew has gotten a note on this.
pandas/core/generic.py
Outdated
@@ -6985,17 +7054,46 @@ def first(self, offset): | |||
Convenience method for subsetting initial periods of time series data | |||
based on a date offset. | |||
|
|||
Raises | |||
----- | |||
NotImplementedError |
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.
should also be a TypeError
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.
Oh, I read the code wrong here, it already raised TypeError. doc string changed
9a32d80
to
3a6de78
Compare
Hello @topper-123! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on May 06, 2018 at 12:07 Hours UTC |
Comments addressed. |
3a5ad92
to
d482d3e
Compare
Is this ok, @jreback? |
3cee9f2
to
8235074
Compare
""" | ||
from pandas.tseries.frequencies import to_offset | ||
if not isinstance(self.index, DatetimeIndex): | ||
raise NotImplementedError("'first' only supports a DatetimeIndex " | ||
"index") | ||
raise TypeError("'first' only supports a DatetimeIndex 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.
can you add some tests that assert the TypeError? (was this not tested before)?
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.
They were not there beforehand, so I've added.
A question: There exists test for Series.first/last, but not DataFrame.first/last. Should i copy the relevant tests from series/test_timeseries.py
to frame/test_time_series.py
, or is that not relevant?
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.
sure that would be great (do a search for them as well, it maybe that they are elsewhere, but they should be in test_timeseries
0aadb90
to
154e93f
Compare
154e93f
to
e41cfe8
Compare
e41cfe8
to
18025cf
Compare
I've added the tests to |
if anyone has comment: @jorisvandenbossche @TomAugspurger @toobaz otherwise lgtm. |
Looks good.
…On Mon, May 7, 2018 at 5:29 AM, Jeff Reback ***@***.***> wrote:
if anyone has comment: @jorisvandenbossche
<https://github.com/jorisvandenbossche> @TomAugspurger
<https://github.com/TomAugspurger> @toobaz <https://github.com/toobaz>
otherwise lgtm.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20725 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHItvrQkq8pTC54DXy-ewrRM4dyxOgks5twCImgaJpZM4TY95o>
.
|
thank @topper-123 |
Added note that methods
at_time
/between_time
/first
/last
requires that the index is a DateTimeIndex.Added functioning examples to the method doc strings.
Added See Also section to the mentioned method doc string.
EDIT: The doc strings for
DatetimeIndex.indexer_at_time
andDatetimeIndex.indexer_between_time
said they return a timeseries, while in reality they return arrays. I've corrected that, and made some minor updates to those doc strings in addition.