-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: added tests for sparse and date range quantiles #35236
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 1 commit
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 |
---|---|---|
|
@@ -7,14 +7,29 @@ | |
|
||
|
||
class TestDataFrameQuantile: | ||
def test_quantile_sparse(self): | ||
@pytest.mark.parametrize( | ||
"df,expected", | ||
[ | ||
[ | ||
pd.DataFrame( | ||
{ | ||
0: pd.Series(pd.arrays.SparseArray([1, 2])), | ||
1: pd.Series(pd.arrays.SparseArray([3, 4])), | ||
} | ||
), | ||
pd.Series([1.5, 3.5], name=0.5), | ||
], | ||
[ | ||
pd.DataFrame(pd.Series([0.0, None, 1.0, 2.0], dtype="Sparse[float]")), | ||
pd.Series([1.0], name=0.5), | ||
], | ||
], | ||
) | ||
def test_quantile_sparse(self, df, expected): | ||
# GH#17198 | ||
s = pd.Series(pd.arrays.SparseArray([1, 2])) | ||
s1 = pd.Series(pd.arrays.SparseArray([3, 4])) | ||
df = pd.DataFrame({0: s, 1: s1}) | ||
result = df.quantile() | ||
# GH#24600 | ||
result = df.quantile(0.5) | ||
|
||
expected = pd.Series([1.5, 3.5], name=0.5) | ||
tm.assert_series_equal(result, expected) | ||
|
||
def test_quantile(self, datetime_frame): | ||
|
@@ -59,6 +74,18 @@ def test_quantile(self, datetime_frame): | |
expected = Series([3.0, 4.0], index=[0, 1], name=0.5) | ||
tm.assert_series_equal(result, expected) | ||
|
||
def test_quantile_date_range(self): | ||
# GH 2460 | ||
|
||
dti = pd.date_range("2016-01-01", periods=3, tz="US/Pacific") | ||
ser = pd.Series(dti) | ||
df = pd.DataFrame(ser) | ||
|
||
result = df.quantile(0.5) | ||
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. expected is NO values? 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. It has no values unless it is run with numeric_only set to false. So it would be It probably makes more sense to change it and set numeric_only to false correct? |
||
expected = pd.Series([], index=[], name=0.5, dtype=np.float64) | ||
|
||
tm.assert_series_equal(result, expected) | ||
|
||
def test_quantile_axis_mixed(self): | ||
|
||
# mixed on axis=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.
hmm this should work with
df.quantile()
yes?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 think we test this elsewhere so prob ok 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.
Yes
df.quantile()
works the same. I can change this.