-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: show percentiles in timestamp describe (#30164) #30209
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 all commits
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 |
---|---|---|
|
@@ -253,52 +253,19 @@ def test_describe_tz_values(self, tz_naive_fixture): | |
|
||
expected = DataFrame( | ||
{ | ||
"s1": [ | ||
5, | ||
np.nan, | ||
np.nan, | ||
np.nan, | ||
np.nan, | ||
np.nan, | ||
2, | ||
1.581139, | ||
0, | ||
1, | ||
2, | ||
3, | ||
4, | ||
], | ||
"s1": [5, 2, 0, 1, 2, 3, 4, 1.581139], | ||
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. do we have sufficient tests for timedeltas? can you create a test for Period (which likely don't work), if you'd just xfail it (alt if you'd create an issue) |
||
"s2": [ | ||
5, | ||
5, | ||
s2.value_counts().index[0], | ||
1, | ||
Timestamp(2018, 1, 3).tz_localize(tz), | ||
start.tz_localize(tz), | ||
s2[1], | ||
s2[2], | ||
s2[3], | ||
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", | ||
], | ||
index=["count", "mean", "min", "25%", "50%", "75%", "max", "std"], | ||
) | ||
result = df.describe(include="all") | ||
tm.assert_frame_equal(result, expected) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import numpy as np | ||
|
||
from pandas import Series, Timestamp, date_range | ||
from pandas import Period, Series, Timedelta, Timestamp, date_range | ||
import pandas._testing as tm | ||
|
||
|
||
|
@@ -29,6 +29,36 @@ def test_describe(self): | |
) | ||
tm.assert_series_equal(result, expected) | ||
|
||
s = Series( | ||
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. ok for now, in a followon we want to parameterize these. |
||
[ | ||
Timedelta("1 days"), | ||
Timedelta("2 days"), | ||
Timedelta("3 days"), | ||
Timedelta("4 days"), | ||
Timedelta("5 days"), | ||
], | ||
name="timedelta_data", | ||
) | ||
result = s.describe() | ||
expected = Series( | ||
[5, s[2], s.std(), s[0], s[1], s[2], s[3], s[4]], | ||
name="timedelta_data", | ||
index=["count", "mean", "std", "min", "25%", "50%", "75%", "max"], | ||
) | ||
tm.assert_series_equal(result, expected) | ||
|
||
s = Series( | ||
[Period("2020-01", "M"), Period("2020-01", "M"), Period("2019-12", "M")], | ||
name="period_data", | ||
) | ||
result = s.describe() | ||
expected = Series( | ||
[3, 2, s[0], 2], | ||
name="period_data", | ||
index=["count", "unique", "top", "freq"], | ||
) | ||
tm.assert_series_equal(result, expected) | ||
|
||
def test_describe_empty_object(self): | ||
# https://github.com/pandas-dev/pandas/issues/27183 | ||
s = Series([None, None], dtype=object) | ||
|
@@ -57,13 +87,14 @@ def test_describe_with_tz(self, tz_naive_fixture): | |
expected = Series( | ||
[ | ||
5, | ||
5, | ||
s.value_counts().index[0], | ||
1, | ||
Timestamp(2018, 1, 3).tz_localize(tz), | ||
start.tz_localize(tz), | ||
s[1], | ||
s[2], | ||
s[3], | ||
end.tz_localize(tz), | ||
], | ||
name=name, | ||
index=["count", "unique", "top", "freq", "first", "last"], | ||
index=["count", "mean", "min", "25%", "50%", "75%", "max"], | ||
) | ||
tm.assert_series_equal(result, expected) |
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 move to api changes section.