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: first() loses the timezone in groupby #15884

Closed
chrisaycock opened this issue Apr 3, 2017 · 2 comments

Comments

3 participants
@chrisaycock
Copy link
Contributor

commented Apr 3, 2017

need a systematic test of all groupby methods here.

This works as expected:

pd.DataFrame({'time': [pd.Timestamp('2012-01-01 13:00:00+00:00')],
              'A': [3]}).groupby('A', as_index=False).head(1)

However, this loses the timezone:

pd.DataFrame({'time': [pd.Timestamp('2012-01-01 13:00:00+00:00')],
              'A': [3]}).groupby('A', as_index=False).first()

@chrisaycock chrisaycock changed the title first() loses the timezone BUG: first() loses the timezone Apr 3, 2017

@jreback

This comment has been minimized.

Copy link
Contributor

commented Apr 3, 2017

so this falls down: https://github.com/pandas-dev/pandas/blob/master/pandas/core/groupby.py#L1929

essentially .values is a DatetimeIndex at this point, not a numpy array. (because its passed block.values higher up). So this needs to be handled.

@jreback jreback added this to the Next Minor Release milestone Apr 3, 2017

@jreback jreback referenced this issue Apr 7, 2017

Closed

skipna added to groupby numeric ops #15772

2 of 4 tasks complete

@jreback jreback modified the milestones: Interesting Issues, Next Major Release Nov 26, 2017

@jreback jreback added this to Dtypes in Interesting Things Nov 26, 2017

@jreback jreback changed the title BUG: first() loses the timezone BUG: first() loses the timezone in groupby Mar 7, 2018

@mroeschke

This comment has been minimized.

Copy link
Member

commented Mar 7, 2018

I believe the solution to this issue xrefs to #19026 (here), where np.asarray will convert the datetimetz dtype to just a datetime dtype.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.