-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: fix+test quantile with empty DataFrame, closes #23925 #27436
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 2 commits
ae2834b
c9ba3e6
b2df6d8
2be56dc
e5275a0
c83255c
47e8896
9705eb5
c8bd534
b936a14
74c1d4d
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 |
---|---|---|
|
@@ -439,7 +439,7 @@ def test_quantile_nat(self): | |
) | ||
tm.assert_frame_equal(res, exp) | ||
|
||
def test_quantile_empty(self): | ||
def test_quantile_empty_no_rows(self): | ||
|
||
# floats | ||
df = DataFrame(columns=["a", "b"], dtype="float64") | ||
|
@@ -467,3 +467,14 @@ def test_quantile_empty(self): | |
|
||
# FIXME (gives NaNs instead of NaT in 0.18.1 or 0.19.0) | ||
# res = df.quantile(0.5, numeric_only=False) | ||
|
||
def test_quantile_empty_no_columns(self): | ||
# GH#23925 _get_numeric_data may drop all columns | ||
df = pd.DataFrame(pd.date_range("1/1/18", periods=5)) | ||
result = df.quantile(0.5) | ||
expected = pd.Series([], index=[], name=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. can you add a name to the index of the frame which I think should propagate here? 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. good point. i think it should be df.columns.name that propagates. It looks like DataFrame_get_numeric_data isn't retaining the columns names, will open a separate issue 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. also I pushed the 1.0 whatsnew if you rebase |
||
tm.assert_series_equal(result, expected) | ||
|
||
result = df.quantile([0.5]) | ||
expected = pd.DataFrame([], index=[0.5], columns=[]) | ||
tm.assert_frame_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.
might be worth testing this with timedelta & period data as well (just to confirm that they work), but can do followup.