-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Series.describe returns first and last for tz-aware datetimes #21332
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 7 commits
39f0e67
be19766
7ddf706
3eeec04
0a9e0c6
7fe331d
dd13740
0af4758
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 |
---|---|---|
|
@@ -417,6 +417,28 @@ 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): | ||
# GH 21332 | ||
tz = tz_naive_fixture | ||
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 add a comment with the issue number, like |
||
s1 = Series(range(5)) | ||
start = Timestamp(2018, 1, 1) | ||
end = Timestamp(2018, 1, 5) | ||
s2 = Series(date_range(start, end, tz=tz)) | ||
df = pd.DataFrame({'s1': s1, 's2': s2}) | ||
|
||
expected = DataFrame({'s1': [5, np.nan, np.nan, np.nan, np.nan, np.nan, | ||
2, 1.581139, 0, 1, 2, 3, 4], | ||
's2': [5, 5, s2.value_counts().index[0], 1, | ||
start.tz_localize(tz), | ||
end.tz_localize(tz), np.nan, np.nan, | ||
np.nan, np.nan, np.nan, np.nan, np.nan]}, | ||
index=['count', 'unique', 'top', 'freq', 'first', | ||
'last', 'mean', 'std', 'min', '25%', '50%', | ||
'75%', 'max'] | ||
) | ||
res = df.describe(include='all') | ||
tm.assert_frame_equal(res, expected) | ||
|
||
def test_reduce_mixed_frame(self): | ||
# GH 6806 | ||
df = DataFrame({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,6 +336,23 @@ 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 commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a comment with the issue number, like |
||
# GH 21332 | ||
tz = tz_naive_fixture | ||
name = tz_naive_fixture | ||
start = Timestamp(2018, 1, 1) | ||
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. 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 commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
result = s.describe() | ||
expected = Series( | ||
[5, 5, s.value_counts().index[0], 1, start.tz_localize(tz), | ||
end.tz_localize(tz) | ||
], | ||
name=name, | ||
index=['count', 'unique', 'top', 'freq', 'first', 'last'] | ||
) | ||
tm.assert_series_equal(result, expected) | ||
|
||
def test_argsort(self): | ||
self._check_accum_op('argsort', check_dtype=False) | ||
argsorted = self.ts.argsort() | ||
|
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.