-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Series.describe returns first and last for tz-aware datetimes #21332
Series.describe returns first and last for tz-aware datetimes #21332
Conversation
@@ -336,6 +336,31 @@ def test_describe(self): | |||
index=['count', 'unique', 'top', 'freq']) | |||
tm.assert_series_equal(result, expected) | |||
|
|||
start = Timestamp(2018, 1, 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.
can u add a new test and/or parametrize on the tz
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.
done
Codecov Report
@@ Coverage Diff @@
## master #21332 +/- ##
==========================================
+ Coverage 91.93% 91.94% +<.01%
==========================================
Files 159 160 +1
Lines 49733 49738 +5
==========================================
+ Hits 45721 45730 +9
+ Misses 4012 4008 -4
Continue to review full report at Codecov.
|
@@ -336,6 +336,25 @@ def test_describe(self): | |||
index=['count', 'unique', 'top', 'freq']) | |||
tm.assert_series_equal(result, expected) | |||
|
|||
@pytest.mark.parametrize("tz", [None, "US/Eastern"]) | |||
def test_describe_dt(self, tz): | |||
if tz is None: |
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.
You can put this in pytest.mark.parametrize
as well.
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.
sure, will do
@@ -336,6 +336,25 @@ def test_describe(self): | |||
index=['count', 'unique', 'top', 'freq']) | |||
tm.assert_series_equal(result, expected) | |||
|
|||
@pytest.mark.parametrize("tz", [None, "US/Eastern"]) | |||
def test_describe_dt(self, tz): |
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 make the test name a bit more descriptive, like test_describe_timezone_dtype
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.
I don't quite think that's the right name since the test also tests tz-naive datetimes. How about test_describe_dt_dtype
?
It would be good to add (or see if there's) a test for |
I looked through the existing tests for |
@jreback made the suggested change, ready to merge or further changes desired? |
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.
looks good, some comments, can you add a note in 0.24.0 in bug fix section.
@@ -336,6 +336,24 @@ def test_describe(self): | |||
index=['count', 'unique', 'top', 'freq']) | |||
tm.assert_series_equal(result, expected) | |||
|
|||
@pytest.mark.parametrize("tz, name", [ |
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.
can you use the tz_naive_fixture here
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.
done
(None, "tz-naive"), | ||
("US/Eastern", "tz-aware") | ||
]) | ||
def test_describe_dt(self, tz, name): |
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.
can you name: test_describe_with_tz
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.
done
def test_describe_dt(self, tz, name): | ||
start = Timestamp(2018, 1, 1) | ||
end = Timestamp(2018, 1, 5) | ||
s = Series(date_range(start, end, tz=tz), name=name) |
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.
can you add a test for frame as well (in the appropraite file)
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.
done
96ac31e
to
a269f5f
Compare
Changes made:
Ready for re-review |
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -131,7 +131,7 @@ Datetimelike | |||
|
|||
- Fixed bug where two :class:`DateOffset` objects with different ``normalize`` attributes could evaluate as equal (:issue:`21404`) | |||
- Bug in :class:`Index` with ``datetime64[ns, tz]`` dtype that did not localize integer data correctly (:issue:`20964`) | |||
- | |||
- Fixed bug where `describe` method on tz-aware datetimes did not show `first` and `last` result (:issue:`21328`) |
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.
Instead of describe
, could you adjust it to :meth:DataFrame.describe
and :meth:Series.describe
. It will render nicer in the whatsnew doc
pandas/tests/frame/test_analytics.py
Outdated
@@ -417,6 +417,27 @@ def test_describe_timedelta_values(self): | |||
"max 5 days 00:00:00 0 days 05:00:00") | |||
assert repr(res) == exp_repr | |||
|
|||
def test_describe_tz_values(self, tz_naive_fixture): | |||
tz = tz_naive_fixture |
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 add a comment with the issue number, like GH #21332
@@ -336,6 +336,22 @@ def test_describe(self): | |||
index=['count', 'unique', 'top', 'freq']) | |||
tm.assert_series_equal(result, expected) | |||
|
|||
def test_describe_with_tz(self, tz_naive_fixture): |
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 add a comment with the issue number, like GH #21332
Just a few documentation comments, one merge conflict, otherwise LGTM. |
9a7deca
to
dd13740
Compare
Thanks @mroeschke . fixed. |
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -295,6 +295,8 @@ Datetimelike | |||
^^^^^^^^^^^^ | |||
|
|||
- Fixed bug where two :class:`DateOffset` objects with different ``normalize`` attributes could evaluate as equal (:issue:`21404`) | |||
- Bug in :class:`Index` with ``datetime64[ns, tz]`` dtype that did not localize integer data correctly (:issue:`20964`) | |||
- Fixed bug where :meth:`DataFrame.describe` and :meth:`Series.describe` on tz-aware datetimes did not show `first` and `last` result (:issue:`21328`) |
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.
One more nit: Could you move this entry to the timezones section below?
Also the entry above this one exists in the timezone section already i.e. you can remove it.
Thanks for you patience.
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.
Done, no problem.
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.
@mroeschke merge when you are happy with this.
Thanks @louispotok! |
…-dev#21332) * Series.describe returns first and last for tz-aware datetimes GH issue 21328 * parameterize tests * parameterize names * use tz_naive_fixture and fix top * add tz describe test for df * add bugfix to whatsnew * fix formatting in whatsnew and add issue number to tests * final bugfix
GH issue 21328
git diff upstream/master -u -- "*.py" | flake8 --diff