Skip to content

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

Merged
merged 6 commits into from
Sep 7, 2017

Conversation

mroeschke
Copy link
Member

@jreback created a new method _get_named_field based on your comment in the issue thread.

@jreback jreback added Bug Datetime Datetime data dtype Timezones Timezone data dtype labels Aug 30, 2017
@@ -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`)
Copy link
Contributor

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)

@@ -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):
Copy link
Contributor

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

return val

cpdef _get_field(self, field):
val = self._maybe_convert_value_to_local()
Copy link
Contributor

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
Copy link

codecov bot commented Sep 1, 2017

Codecov Report

Merging #17377 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 88.92% <ø> (ø) ⬆️
#single 40.25% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.72% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8351f86...18852f4. Read the comment docs.

@codecov
Copy link

codecov bot commented Sep 1, 2017

Codecov Report

Merging #17377 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 88.92% <ø> (-0.01%) ⬇️
#single 40.25% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/io/parquet.py 65.38% <0%> (-0.37%) ⬇️
pandas/core/frame.py 97.72% <0%> (-0.1%) ⬇️
pandas/core/indexes/base.py 96.29% <0%> (ø) ⬆️
pandas/core/indexes/multi.py 96.9% <0%> (ø) ⬆️
pandas/plotting/_core.py 82.69% <0%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8351f86...ddaa4e3. Read the comment docs.

@mroeschke
Copy link
Member Author

cdef'd _maybe_convert_value_to_local and val argument in related function and all green.

Copy link
Contributor

@jreback jreback left a 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"""
Copy link
Contributor

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:
Copy link
Contributor

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()
Copy link
Contributor

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

@jreback jreback added this to the 0.21.0 milestone Sep 5, 2017
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
Copy link
Contributor

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.

@jreback jreback merged commit 3a12687 into pandas-dev:master Sep 7, 2017
@jreback
Copy link
Contributor

jreback commented Sep 7, 2017

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Timestamp.weekday_name uses UTC instead of given timezone
2 participants