Skip to content

Fix #28552 Add test for DataFrame min/max preserve timezone #33905

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 4 commits into from May 12, 2020
Merged
Changes from 2 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
16 changes: 16 additions & 0 deletions pandas/tests/frame/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,19 @@ def test_constructor_data_aware_dtype_naive(self, tz_aware_fixture):
result = DataFrame({"d": [pd.Timestamp("2019", tz=tz)]}, dtype="datetime64[ns]")
expected = DataFrame({"d": [pd.Timestamp("2019")]})
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize(
"initial",
["2018-10-08 13:36:45+00:00", "2018-10-08 13:36:45+03:00"], # Non-UTC timezone
)
@pytest.mark.parametrize("method", ["min", "max"])
def test_preserve_timezone(self, initial: str, method):
# GH 28552
# Given
initial_dt = pd.to_datetime(initial)
expected = pd.Series([initial_dt])
df = DataFrame([expected])
# When
result: pd.Series = getattr(df, method)(axis=1)
# Then
tm.assert_series_equal(result, expected)