Skip to content

TST: Add a regression test for the timezone issue #29097

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 1 commit into from
Oct 20, 2019

Conversation

grigoriosgiann
Copy link
Contributor

@grigoriosgiann grigoriosgiann commented Oct 19, 2019

Add a regression test to ensure that the timezone doesn't get removed
when using df.apply.

@grigoriosgiann grigoriosgiann changed the title TST: Add regression test for the timezone issue TST: Add a regression test for the timezone issue Oct 19, 2019
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

@grigoriosgiann Thanks for the PR.

pd.Timestamp("2019-03-15 12:34:34.660000+0000", tz="UTC"),
],
)
df2 = df.apply(lambda x: x.name, axis=1)
Copy link
Member

Choose a reason for hiding this comment

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

call this result

Comment on lines 373 to 374
assert df[0].keys().dtype == df2.dtypes
assert (df[0].keys().values == df2.values).all()
Copy link
Member

Choose a reason for hiding this comment

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

construct the expected DataFrame explicitly and do tm.assert_frame_equals(result,expected)

@simonjayhawkins simonjayhawkins added Apply Apply, Aggregate, Transform, Map Testing pandas testing functions or related to the test suite Timezones Timezone data dtype labels Oct 19, 2019
@pep8speaks
Copy link

pep8speaks commented Oct 19, 2019

Hello @grigoriosgiann! 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 2019-10-20 10:52:05 UTC

@grigoriosgiann
Copy link
Contributor Author

@grigoriosgiann Thanks for the PR.

Thanks for the feedback! 😄
Let me know if there is anything else I should adjust. 🙂

@jreback jreback added this to the 1.0 milestone Oct 19, 2019
@@ -356,3 +356,17 @@ def test_loc_label_slicing(self):
expected = ser.iloc[:-1]

tm.assert_series_equal(result, expected)

def test_apply_datetime_tz_issue(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

looks good, can you move to pandas/tests/frame/test_apply.py

ping on green.

@jreback
Copy link
Contributor

jreback commented Oct 19, 2019

lgtm. ping on green.

@grigoriosgiann
Copy link
Contributor Author

grigoriosgiann commented Oct 19, 2019

Azure appears to be stuck...
Is there a way to rerun checks?
Or should I just git commit --amend --no-edit & re-push?

Edit: Force re-pushed since azure failed after some time (https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=19252&view=logs)

@grigoriosgiann grigoriosgiann force-pushed the test-dt-apply branch 3 times, most recently from bd070d4 to b528352 Compare October 20, 2019 09:17
Add a regression test to ensure that the timezone doesn't get removed
when using `df.apply`.
@grigoriosgiann
Copy link
Contributor Author

Ping, it's green!😄

@jreback jreback merged commit e623f0f into pandas-dev:master Oct 20, 2019
@jreback
Copy link
Contributor

jreback commented Oct 20, 2019

thanks @grigoriosgiann

RonKbS added a commit to RonKbS/pandas that referenced this pull request Oct 20, 2019
Add a regression test for the timezone issue (pandas-dev#29097)
jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this pull request Oct 23, 2019
HawkinsBA pushed a commit to HawkinsBA/pandas that referenced this pull request Oct 29, 2019
Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map 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.

df.apply(lambda x: x.name, axis=1) lose timezone info when df.index is tz-aware.
4 participants