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

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

merged 4 commits into from May 12, 2020

Conversation

ghost
Copy link

@ghost ghost commented Apr 30, 2020

Here's a test discussed in #28552. mean and other aggregates except for min and max are not covered since they don't support datetimes - it's a nan being returned.

@pep8speaks
Copy link

pep8speaks commented Apr 30, 2020

Hello @dair-targ! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-05-12 11:57:56 UTC

"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])
Copy link
Member

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 do getattr(df, method)(axis=1)

Copy link
Author

Choose a reason for hiding this comment

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

Addressed.

# When
actual_df = method(df, axis=1)
# Then
assert actual_df[0].tz == initial_dt.tz
Copy link
Member

Choose a reason for hiding this comment

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

Could you rename the results result and expected and compare 2 DataFrame or Series objects and use tm.assert_equal(result, expected)

Copy link
Author

Choose a reason for hiding this comment

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

Addressed. Please note that min and max methods of the DataFrame both return Series, so I choose to use the tm.assert_series_equal instead in the same manner as it is being used in test_frame_no_datetime64_dtype.

@ghost
Copy link
Author

ghost commented May 9, 2020

@mroeschke thanks for review! I hope I've addressed all the issues - would you mind to review it again?

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

LGTM

@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Testing pandas testing functions or related to the test suite Timezones Timezone data dtype labels May 11, 2020
@jreback jreback added this to the 1.1 milestone May 12, 2020
@jreback jreback merged commit 4db1322 into pandas-dev:master May 12, 2020
@jreback
Copy link
Contributor

jreback commented May 12, 2020

thanks @dair-targ

@ghost ghost deleted the GH-28552 branch May 12, 2020 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode Testing pandas testing functions or related to the test suite Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFrame[list[Series[datetime64ns, tz]]] drops timezone information
3 participants