-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Add timetz attribute to DatetimeIndex #22132
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
Add timetz attribute to DatetimeIndex #22132
Conversation
…etimeIndex_and_Timestamp
…etimeIndex_and_Timestamp
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -180,6 +180,7 @@ Other Enhancements | |||
- :func:`~DataFrame.to_csv` and :func:`~DataFrame.to_json` now support ``compression='infer'`` to infer compression based on filename (:issue:`15008`) | |||
- :func:`to_timedelta` now supports iso-formated timedelta strings (:issue:`21877`) | |||
- :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`) | |||
- :class:`DatetimeIndex` gained :attr:`~DatetimeIndex.timetz` attribute. Returns time with timezone information (:issue:`21358`) |
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 don't think you need the
~
before~DatetimeIndex.timetz
- Can you clarify that this returns local time with timezone information
@pytest.mark.parametrize('tz', [ | ||
dateutil.tz.gettz('US/Eastern'), dateutil.tz.gettz('US/Pacific'), | ||
dateutil.tz.gettz('UTC')]) | ||
def test_timetz_accessor(self, tz): |
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.
Instead could you use the tz_naive_fixture
?
Line 290 in 26b3e7d
def tz_naive_fixture(request): |
Looks good overall!
|
I didn't add a timetz attribute to Timestamp yet because it inherits a timetz method directly from standard library datetime. So should we add an attribute on top of that? And I assume we don't have any tests right now because it is a standard library thing |
I don't think you have to add a |
Codecov Report
@@ Coverage Diff @@
## master #22132 +/- ##
==========================================
+ Coverage 92.06% 92.06% +<.01%
==========================================
Files 169 169
Lines 50694 50696 +2
==========================================
+ Hits 46671 46673 +2
Misses 4023 4023
Continue to review full report at Codecov.
|
Ok, gotcha |
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 we test for timetz on Timestamp (only in PY3 I think)?
@@ -1739,6 +1739,7 @@ Time/Date Components | |||
DatetimeIndex.nanosecond | |||
DatetimeIndex.date | |||
DatetimeIndex.time |
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 add in the api section for Timestamp though
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 timetz method was already there for Timestamp, and I added the property for DatetimeIndex
…etimeIndex_and_Timestamp
…etimeIndex_and_Timestamp
Sorry forgot one more thing; could you add a After that one test LGTM. |
I find an attribute for this is very confusing, as compared to the function call similar to |
For the PR, I think we should leave it as a property for now since we break this property vs. method for other (Although I don't even know why these are method calls for |
…etimeIndex_and_Timestamp
…etimeIndex_and_Timestamp
…etimeIndex_and_Timestamp
@mroeschke how does it look? |
Any other comments @jreback? |
thanks @jquinon nice patch! |
git diff upstream/master -u -- "*.py" | flake8 --diff
I only added timetz to DatetimeIndex because there was already a timetz method in Timestamp that did essentially the same thing. If it is still worth adding to Timestamp though, I can certainly do that.