Skip to content
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

BUG: tz aware Timestamp field accessors returns local values (#13303) #15740

Closed
wants to merge 1 commit into from

Conversation

mroeschke
Copy link
Member

Previously, calling a date/time attribute with Timestamp that's tz aware (e.g. Timestamp('...', tz='...').dayofyear) would return the attribute in UTC instead of the local tz.

@codecov
Copy link

codecov bot commented Mar 20, 2017

Codecov Report

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

@@            Coverage Diff             @@
##           master   #15740      +/-   ##
==========================================
- Coverage   91.01%   90.99%   -0.02%     
==========================================
  Files         143      143              
  Lines       49401    49401              
==========================================
- Hits        44961    44952       -9     
- Misses       4440     4449       +9
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/common.py 90.96% <0%> (-0.34%) ⬇️
pandas/core/frame.py 97.86% <0%> (-0.1%) ⬇️
pandas/tseries/index.py 95.39% <0%> (+0.09%) ⬆️

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 8bde21a...b78b333. Read the comment docs.

@jorisvandenbossche jorisvandenbossche added Bug Timezones Timezone data dtype labels Mar 20, 2017
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Small comment

val = self.value
if self.tz is not None and not _is_utc(self.tz):
val = tz_convert_single(self.value, 'UTC', self.tz)
out = get_date_field(np.array([val], dtype=np.int64), field)
return int(out[0])

cpdef _get_start_end_field(self, field):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't check, but does this _get_start_end_field needs the same ?

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 ok, get_date_field handles an i8 only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean with get_date_field, but this example seems to be wrong:

In [3]: pd.Timestamp("2014-01-01 00:00:00+01:00").is_month_start
Out[3]: False

In [4]: pd.Timestamp("2014-01-01 00:00:00").is_month_start
Out[4]: True

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh sorry, was looking at something else. get_start_end_field looks to need fixing as well. thanks @jorisvandenbossche

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, get_date_field was on three lines above

@jreback
Copy link
Contributor

jreback commented Mar 20, 2017

can you add similar type tests for DatetimeIndex (IOW with a tz) in pandas/tests/indexes/datetimes/test_misc.py

…dev#13303)

Add whatsnew

Add tests for datetimeindex and fix Timestamp start/end attributes
@jreback
Copy link
Contributor

jreback commented Mar 20, 2017

lgtm.

@jreback jreback added this to the 0.20.0 milestone Mar 20, 2017
@jreback jreback closed this in 771e36c Mar 20, 2017
@mroeschke
Copy link
Member Author

Thanks @jreback!

AnkurDedania pushed a commit to AnkurDedania/pandas that referenced this pull request Mar 21, 2017
…dev#13303)

closes pandas-dev#13303

Previously, calling a date/time attribute with Timestamp that's tz
aware (e.g. `Timestamp('...', tz='...').dayofyear`) would return the
attribute in UTC instead of the local tz.

Author: Matt Roeschke <[email protected]>

Closes pandas-dev#15740 from mroeschke/fix_13303 and squashes the following commits:

b78b333 [Matt Roeschke] BUG: tz aware Timestamp field accessors returns local values (pandas-dev#13303)
mattip pushed a commit to mattip/pandas that referenced this pull request Apr 3, 2017
…dev#13303)

closes pandas-dev#13303

Previously, calling a date/time attribute with Timestamp that's tz
aware (e.g. `Timestamp('...', tz='...').dayofyear`) would return the
attribute in UTC instead of the local tz.

Author: Matt Roeschke <[email protected]>

Closes pandas-dev#15740 from mroeschke/fix_13303 and squashes the following commits:

b78b333 [Matt Roeschke] BUG: tz aware Timestamp field accessors returns local values (pandas-dev#13303)
@mroeschke mroeschke deleted the fix_13303 branch December 20, 2017 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timezone aware Timestamp.dayofyear does not report correct day
3 participants