-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Return local Timestamp.weekday_name attribute (#17354) #17377
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
doc/source/whatsnew/v0.21.0.txt
Outdated
@@ -342,6 +342,7 @@ Conversion | |||
- Fixed the return type of ``IntervalIndex.is_non_overlapping_monotonic`` to be a Python ``bool`` for consistency with similar attributes/methods. Previously returned a ``numpy.bool_``. (:issue:`17237`) | |||
- Bug in ``IntervalIndex.is_non_overlapping_monotonic`` when intervals are closed on both sides and overlap at a point (:issue:`16560`) | |||
- Bug in :func:`Series.fillna` returns frame when ``inplace=True`` and ``value`` is dict (:issue:`16156`) | |||
- Bug in ``Timestamp.weekday_name`` returning a UTC-based weekday name when localized to a timezone (:issue:`17354`) |
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.
you can do :func:`Timestamp.weekday_name`
I think (might need to be attr actually)
pandas/_libs/tslib.pyx
Outdated
@@ -1268,13 +1266,23 @@ cdef class _Timestamp(datetime): | |||
# same timezone if specified) | |||
return datetime.__sub__(self, other) | |||
|
|||
cpdef _get_field(self, field): | |||
cpdef _maybe_convert_value_to_local(self): |
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 can be just cdef and should return int64_t
pandas/_libs/tslib.pyx
Outdated
return val | ||
|
||
cpdef _get_field(self, field): | ||
val = self._maybe_convert_value_to_local() |
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.
you can type val as cdef: int64_t
(same for _get_named_field
)
Codecov Report
@@ Coverage Diff @@
## master #17377 +/- ##
==========================================
- Coverage 91.16% 91.14% -0.02%
==========================================
Files 163 163
Lines 49581 49581
==========================================
- Hits 45199 45190 -9
- Misses 4382 4391 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17377 +/- ##
==========================================
- Coverage 91.16% 91.14% -0.03%
==========================================
Files 163 163
Lines 49581 49587 +6
==========================================
- Hits 45199 45194 -5
- Misses 4382 4393 +11
Continue to review full report at Codecov.
|
cdef'd |
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.
some cdef comments. lgtm. ping when changed / pushed.
@@ -1268,13 +1266,27 @@ cdef class _Timestamp(datetime): | |||
# same timezone if specified) | |||
return datetime.__sub__(self, other) | |||
|
|||
cpdef _get_field(self, field): | |||
cdef int64_t _maybe_convert_value_to_local(self): | |||
"""Convert UTC i8 value to local i8 value if tz exists""" |
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.
you need to add a
cdef int64_t val
here in order to type it
return val | ||
|
||
cpdef _get_field(self, field): | ||
cdef: |
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.
like this
cpdef _get_field(self, field): | ||
cdef: | ||
int64_t val | ||
val = self._maybe_convert_value_to_local() |
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.
if you can type out in these (ndarray[int32_t]) i think
pandas/_libs/tslib.pyx
Outdated
int64_t val | ||
ndarray[int64_t] date_array = np.empty(1, dtype=np.int64) | ||
val = self._maybe_convert_value_to_local() | ||
date_array[0] = val |
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 is overkill to type the input ndarray itself
it was out
which was looking to type, though not a big deal, so just remove the date_array temp. ping on green.
thanks! |
git diff upstream/master -u -- "*.py" | flake8 --diff
@jreback created a new method
_get_named_field
based on your comment in the issue thread.