-
Notifications
You must be signed in to change notification settings - Fork 358
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
Implemented GroupBy.median() #1957
Conversation
FYI: we're doing same thing in median for DataFrame and Series. koalas/databricks/koalas/generic.py Lines 1898 to 1904 in 9e8d99b
|
Codecov Report
@@ Coverage Diff @@
## master #1957 +/- ##
=======================================
Coverage 94.59% 94.60%
=======================================
Files 49 49
Lines 10882 10890 +8
=======================================
+ Hits 10294 10302 +8
Misses 588 588
Continue to review full report at Codecov.
|
Otherwise, LGTM! |
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 fix the conflicts as well?
Otherwise, LGTM.
@@ -2343,6 +2344,73 @@ def get_group(self, name) -> Union[DataFrame, Series]: | |||
|
|||
return DataFrame(internal) | |||
|
|||
def median(self, numeric_only=True, accuracy=10000) -> Union[DataFrame, Series]: |
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.
Are numeric_only
and accuracy
unknown types?
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.
We should add more type hints for function arguments in the separate PR.
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, I'll add in the separated PR.
Thanks for the review!
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.
Oh, anyway numeric_only
only supports for True
since this is only for pandas compatibility.
Should we add type hints as bool
though ?
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.
Yep, it must be bool
, and accuracy
must be int
?
There are other similar places in the file or the other files, we can do it in a batch.
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.
Sounds good. I will take a look and add type hints throughout the whole file next week !
Thanks! I'd merge this now. |
This PR proposes
GroupBy.median()
.Note: the result can be slightly different from pandas since we use an approximated median based upon approximate percentile computation because computing median across a large dataset is extremely expensive.
ref #1929