Skip to content
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

Added ddof parameter for GroupBy.std() and GroupBy.var() #1994

Merged
merged 2 commits into from
Jan 7, 2021

Conversation

itholic
Copy link
Contributor

@itholic itholic commented Jan 5, 2021

Added missing parameter ddof for GroupBy.std() and GroupBy.var().

>>> kdf = ks.DataFrame(
...     {
...         "a": [1, 2, 6, 4, 4, 6, 4, 3, 7],
...         "b": [4, 2, 7, 3, 3, 1, 1, 1, 2],
...         "c": [4, 2, 7, 3, None, 1, 1, 1, 2],
...         "d": list("abcdefght"),
...     },
...     index=[0, 1, 3, 5, 6, 8, 9, 9, 9],
... )
>>> kdf
   a  b    c  d
0  1  4  4.0  a
1  2  2  2.0  b
3  6  7  7.0  c
5  4  3  3.0  d
6  4  3  NaN  e
8  6  1  1.0  f
9  4  1  1.0  g
9  3  1  1.0  h
9  7  2  2.0  t

# std
>>> kdf.groupby("a").std(ddof=1)
          b         c
a
7       NaN       NaN
6  4.242641  4.242641
1       NaN       NaN
3       NaN       NaN
2       NaN       NaN
4  1.154701  1.414214

>>> kdf.groupby("a").std(ddof=0)
          b    c
a
7  0.000000  0.0
6  3.000000  3.0
1  0.000000  0.0
3  0.000000  0.0
2  0.000000  0.0
4  0.942809  1.0

# var
>>> kdf.groupby("a").var(ddof=1)
           b     c
a
7        NaN   NaN
6  18.000000  18.0
1        NaN   NaN
3        NaN   NaN
2        NaN   NaN
4   1.333333   2.0

>>> kdf.groupby("a").var(ddof=0)
          b    c
a
7  0.000000  0.0
6  9.000000  9.0
1  0.000000  0.0
3  0.000000  0.0
2  0.000000  0.0
4  0.888889  1.0

@itholic itholic changed the title Add ddof parameter for GroupBy.std() Added ddof parameter for GroupBy.std() Jan 5, 2021
@xinrong-meng
Copy link
Contributor

Looks great! Thanks!

@xinrong-meng xinrong-meng self-requested a review January 5, 2021 16:41
@ueshin
Copy link
Collaborator

ueshin commented Jan 6, 2021

What about GroupBy.var()? Shall we do the same thing for it here?

@itholic itholic changed the title Added ddof parameter for GroupBy.std() Added ddof parameter for GroupBy.std() and GroupBy.var() Jan 7, 2021
@itholic
Copy link
Contributor Author

itholic commented Jan 7, 2021

Sounds good. done !

Copy link
Collaborator

@ueshin ueshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pending tests.

@codecov-io
Copy link

Codecov Report

Merging #1994 (9fbec86) into master (ae5c8d8) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1994      +/-   ##
==========================================
- Coverage   94.52%   94.51%   -0.01%     
==========================================
  Files          50       50              
  Lines       10952    10965      +13     
==========================================
+ Hits        10352    10364      +12     
- Misses        600      601       +1     
Impacted Files Coverage Δ
databricks/koalas/groupby.py 91.60% <100.00%> (+0.02%) ⬆️
databricks/koalas/generic.py 92.60% <0.00%> (-0.01%) ⬇️
databricks/koalas/missing/frame.py 100.00% <0.00%> (ø)
databricks/koalas/missing/series.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae5c8d8...9fbec86. Read the comment docs.

@itholic itholic merged commit f7afe12 into databricks:master Jan 7, 2021
@itholic
Copy link
Contributor Author

itholic commented Jan 7, 2021

Thanks! merging :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants