Skip to content

TST: DataFrameGroupBy.shift Loses TimeZone in datetime64 columns #30153

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 8 commits into from
Dec 11, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime as dt
import re

import numpy as np
Expand Down Expand Up @@ -323,6 +324,13 @@ def test_tz_standardize(self):
dtype = DatetimeTZDtype("ns", dr[0].tz)
assert dtype.tz == tz

def test_dfgroupby_shift_tz(self):
# GH 30134
df = pd.DataFrame({"a": [1, 1], "date": dt.datetime.now(tz=pytz.utc)})
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
df = pd.DataFrame({"a": [1, 1], "date": dt.datetime.now(tz=pytz.utc)})
df = pd.DataFrame({"a": [1, 1], "date": pd.Timestamp.utcnow()})

Slightly more idiomatic

expected = df.dtypes["date"]
result = df.groupby("a").shift(0).dtypes["date"]
assert expected == result
Copy link
Member

Choose a reason for hiding this comment

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

Can you build the actual expected series and use tm.assert_series_equal(result, expected)? Should see examples of this throughout tests



class TestPeriodDtype(Base):
def create(self):
Expand Down