-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Changes from 1 commit
bc76a29
e8268bc
a5295d8
0be205e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", [DataFrame.min, DataFrame.max]) | ||
def test_preserve_timezone(self, initial: str, method): | ||
# GH 28552 | ||
# Given | ||
initial_dt = pd.to_datetime(initial) | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
series = pd.Series([initial_dt]) | ||
df = DataFrame([series]) | ||
# When | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
actual_df = method(df, axis=1) | ||
# Then | ||
assert actual_df[0].tz == initial_dt.tz | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you rename the results There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed. Please note that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use the strings
['min', 'max']
here, and then below you can dogetattr(df, method)(axis=1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.