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

Asobject tz #1383

Closed
wants to merge 2 commits into from
Closed

Asobject tz #1383

wants to merge 2 commits into from

Conversation

changhiskhan
Copy link
Contributor

@@ -540,7 +540,9 @@ def asobject(self):

def _get_object_index(self):
boxed_values = _dt_box_array(self.asi8, self.offset, self.tz)
return Index(boxed_values, dtype=object)
idx = Index(boxed_values, dtype=object)
Copy link
Member

Choose a reason for hiding this comment

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

This isn't actually what I meant in #1345, only to test that the Timestamp or datetime.datetime values in the resulting object arrays have the right tzinfo set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isn't that already in test_timezones.test_asobject_tz_box?

On Sun, Jun 3, 2012 at 1:17 PM, Wes McKinney <
reply@reply.github.com

wrote:

@@ -540,7 +540,9 @@ def asobject(self):

 def _get_object_index(self):
     boxed_values = _dt_box_array(self.asi8, self.offset, self.tz)
  •    return Index(boxed_values, dtype=object)
    
  •    idx = Index(boxed_values, dtype=object)
    

This isn't actually what I meant in #1345, only to test that the Timestamp
or datetime.datetime values in the resulting object arrays have the right
tzinfo set


Reply to this email directly or view it on GitHub:
https://github.com/pydata/pandas/pull/1383/files#r919922

Chang She
Lambda Foundry http://www.lambdafoundry.com

Copy link
Member

Choose a reason for hiding this comment

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

Ah, hmm. good point. asobject_tz_box is actually not doing the right thing (and it disturbs me that the test passes). The issue is that there is a base time zone object that is obtained from pytz.timezone and Timestamps actually receive one of its tzinfos:

In [4]: tz._tzinfos
Out[4]: 
{(datetime.timedelta(-1, 68400),
  datetime.timedelta(0),
  'EST'): <DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD>,
 (datetime.timedelta(-1, 72000),
  datetime.timedelta(0, 3600),
  'EDT'): <DstTzInfo 'US/Eastern' EDT-1 day, 20:00:00 DST>,
 (datetime.timedelta(-1, 72000),
  datetime.timedelta(0, 3600),
  'EPT'): <DstTzInfo 'US/Eastern' EPT-1 day, 20:00:00 DST>,
 (datetime.timedelta(-1, 72000),
  datetime.timedelta(0, 3600),
  'EWT'): <DstTzInfo 'US/Eastern' EWT-1 day, 20:00:00 DST>}

In [5]: type(tz)
Out[5]: pytz.tzfile.US/Eastern

So the fact that that unit test passes is an accident. i'll remove it

Copy link
Member

Choose a reason for hiding this comment

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

Further:

In [2]: rng
Out[2]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2010-02-13 00:00:00, ..., 2010-05-06 00:00:00]
Length: 83, Freq: D, Timezone: US/Eastern

In [3]: rng[0]
Out[3]: Timestamp(2010, 2, 13, 0, 0, tzinfo=<DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD>)

In [4]: rng[-1]
Out[4]: Timestamp(2010, 5, 6, 0, 0, tzinfo=<DstTzInfo 'US/Eastern' EDT-1 day, 20:00:00 DST>)

In [5]: rng[0].tz == rng[-1].tz
Out[5]: False

@wesm
Copy link
Member

wesm commented Jun 3, 2012

Cherry-picked the doc update and skipping the other commit. This is all set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants