-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[DataFrame] Implemented prod, product, added test suite #1994
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4b2a830
implemented prod/product, modified declaration for sum, added pandas …
hsubbaraj f9c5faf
fixed tests
hsubbaraj 6d08249
removed test_analytics file
hsubbaraj f98ac8f
implemented nunique, skew
hsubbaraj 3b29c96
fixed requested changes
hsubbaraj c16109f
added nunique, skew
hsubbaraj 4962ad5
fixed tests in request
hsubbaraj 11a77b6
added newline back
hsubbaraj 571171f
fixed newlines hopefully
hsubbaraj 4601e93
fixed flake8 issues
hsubbaraj 15f58f1
more flake8 issues
hsubbaraj 82bde0e
fixed test for prod
hsubbaraj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -604,7 +604,8 @@ def groupby(self, by=None, axis=0, level=None, as_index=True, sort=True, | |
| return DataFrameGroupBy(self, by, axis, level, as_index, sort, | ||
| group_keys, squeeze, **kwargs) | ||
|
|
||
| def sum(self, axis=None, skipna=True, level=None, numeric_only=None): | ||
| def sum(self, axis=None, skipna=True, level=None, numeric_only=None, | ||
| min_count=1, **kwargs): | ||
| """Perform a sum across the DataFrame. | ||
|
|
||
| Args: | ||
|
|
@@ -616,7 +617,8 @@ def sum(self, axis=None, skipna=True, level=None, numeric_only=None): | |
| """ | ||
| def remote_func(df): | ||
| return df.sum(axis=axis, skipna=skipna, level=level, | ||
| numeric_only=numeric_only) | ||
| numeric_only=numeric_only, min_count=min_count, | ||
| **kwargs) | ||
|
|
||
| return self._arithmetic_helper(remote_func, axis, level) | ||
|
|
||
|
|
@@ -2740,16 +2742,43 @@ def pow(self, other, axis='columns', level=None, fill_value=None): | |
| fill_value) | ||
|
|
||
| def prod(self, axis=None, skipna=None, level=None, numeric_only=None, | ||
| min_count=0, **kwargs): | ||
| raise NotImplementedError( | ||
| "To contribute to Pandas on Ray, please visit " | ||
| "github.com/ray-project/ray.") | ||
| min_count=1, **kwargs): | ||
| """Return the product of the values for the requested axis | ||
|
|
||
| Args: | ||
| axis : {index (0), columns (1)} | ||
| skipna : boolean, default True | ||
| level : int or level name, default None | ||
| numeric_only : boolean, default None | ||
| min_count : int, default 1 | ||
|
|
||
| Returns: | ||
| prod : Series or DataFrame (if level specified) | ||
| """ | ||
| def remote_func(df): | ||
| return df.prod(axis=axis, skipna=skipna, level=level, | ||
| numeric_only=numeric_only, min_count=min_count, | ||
| **kwargs) | ||
|
|
||
| return self._arithmetic_helper(remote_func, axis, level) | ||
|
|
||
| def product(self, axis=None, skipna=None, level=None, numeric_only=None, | ||
| min_count=0, **kwargs): | ||
| raise NotImplementedError( | ||
| "To contribute to Pandas on Ray, please visit " | ||
| "github.com/ray-project/ray.") | ||
| min_count=1, **kwargs): | ||
| """Return the product of the values for the requested axis | ||
|
|
||
| Args: | ||
| axis : {index (0), columns (1)} | ||
| skipna : boolean, default True | ||
| level : int or level name, default None | ||
| numeric_only : boolean, default None | ||
| min_count : int, default 1 | ||
|
|
||
| Returns: | ||
| product : Series or DataFrame (if level specified) | ||
| """ | ||
| return self.prod(axis=axis, skipna=skipna, level=level, | ||
| numeric_only=numeric_only, min_count=min_count, | ||
| **kwargs) | ||
|
|
||
| def quantile(self, q=0.5, axis=0, numeric_only=True, | ||
| interpolation='linear'): | ||
|
|
@@ -4424,4 +4453,4 @@ def _merge_columns(left_columns, right_columns, *args): | |
| """ | ||
| return pd.DataFrame(columns=left_columns, index=[0], dtype='uint8').merge( | ||
| pd.DataFrame(columns=right_columns, index=[0], dtype='uint8'), | ||
| *args).columns | ||
| *args).columns | ||
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,6 +207,8 @@ def test_int_dataframe(): | |
|
|
||
| test_copy(ray_df) | ||
| test_sum(ray_df, pandas_df) | ||
| test_prod(ray_df, pandas_df) | ||
| test_product(ray_df, pandas_df) | ||
| test_abs(ray_df, pandas_df) | ||
| test_keys(ray_df, pandas_df) | ||
| test_transpose(ray_df, pandas_df) | ||
|
|
@@ -367,6 +369,8 @@ def test_float_dataframe(): | |
|
|
||
| test_copy(ray_df) | ||
| test_sum(ray_df, pandas_df) | ||
| test_prod(ray_df, pandas_df) | ||
| test_product(ray_df, pandas_df) | ||
| test_abs(ray_df, pandas_df) | ||
| test_keys(ray_df, pandas_df) | ||
| test_transpose(ray_df, pandas_df) | ||
|
|
@@ -2205,18 +2209,14 @@ def test_pow(): | |
| test_inter_df_math("pow", simple=False) | ||
|
|
||
|
|
||
| def test_prod(): | ||
| ray_df = create_test_dataframe() | ||
|
|
||
| with pytest.raises(NotImplementedError): | ||
| ray_df.prod(None) | ||
|
|
||
| @pytest.fixture | ||
| def test_prod(ray_df, pandas_df): | ||
| assert(ray_df_equals_pandas(ray_df.prod(), pandas_df.prod())) | ||
|
|
||
| def test_product(): | ||
| ray_df = create_test_dataframe() | ||
|
|
||
| with pytest.raises(NotImplementedError): | ||
| ray_df.product() | ||
| @pytest.fixture | ||
| def test_product(ray_df, pandas_df): | ||
| assert(ray_df_equals_pandas(ray_df.product(), pandas_df.product())) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
|
|
@@ -3105,3 +3105,4 @@ def test__doc__(): | |
| pd_obj = getattr(pd.DataFrame, attr, None) | ||
| if callable(pd_obj) or isinstance(pd_obj, property): | ||
| assert obj.__doc__ == pd_obj.__doc__ | ||
|
|
||
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Pandas defines
productas an alias ofprod, so we should do the same.