-
Notifications
You must be signed in to change notification settings - Fork 49
feat: Add quantile statistic #613
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 all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
47118da
feat: Add quantile statistic
TrevorBergeron 030cbea
Merge remote-tracking branch 'github/main' into quantiles
TrevorBergeron 77a982d
fix series.quantile type annotation
TrevorBergeron 856115e
add numeric_only param
TrevorBergeron 55bf22a
Merge remote-tracking branch 'github/main' into quantiles
TrevorBergeron 9983ff0
add limit and fix types
TrevorBergeron 04dcb98
fix mypy
TrevorBergeron d0b3fc3
actually fix mypy
TrevorBergeron 4e60dda
Merge remote-tracking branch 'github/main' into quantiles
TrevorBergeron b76ad9b
fix issue with multiindex isna not impl
TrevorBergeron 677aaf2
fix plot accessor doctests printing progress bar
TrevorBergeron 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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -2504,7 +2504,10 @@ def test_df_melt_default(scalars_dfs): | |
|
||
# Pandas produces int64 index, Bigframes produces Int64 (nullable) | ||
pd.testing.assert_frame_equal( | ||
bf_result, pd_result, check_index_type=False, check_dtype=False | ||
bf_result, | ||
pd_result, | ||
check_index_type=False, | ||
check_dtype=False, | ||
) | ||
|
||
|
||
|
@@ -3029,6 +3032,31 @@ def test_dataframe_aggregates_median(scalars_df_index, scalars_pandas_df_index): | |
) | ||
|
||
|
||
def test_dataframe_aggregates_quantile_mono(scalars_df_index, scalars_pandas_df_index): | ||
q = 0.45 | ||
col_names = ["int64_too", "int64_col", "float64_col"] | ||
bf_result = scalars_df_index[col_names].quantile(q=q).to_pandas() | ||
pd_result = scalars_pandas_df_index[col_names].quantile(q=q) | ||
|
||
# Pandas may produce narrower numeric types, but bigframes always produces Float64 | ||
pd_result = pd_result.astype("Float64") | ||
|
||
pd.testing.assert_series_equal(bf_result, pd_result, check_index_type=False) | ||
|
||
|
||
def test_dataframe_aggregates_quantile_multi(scalars_df_index, scalars_pandas_df_index): | ||
q = [0, 0.33, 0.67, 1.0] | ||
col_names = ["int64_too", "int64_col", "float64_col"] | ||
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. maybe support the 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. added |
||
bf_result = scalars_df_index[col_names].quantile(q=q).to_pandas() | ||
pd_result = scalars_pandas_df_index[col_names].quantile(q=q) | ||
|
||
# Pandas may produce narrower numeric types, but bigframes always produces Float64 | ||
pd_result = pd_result.astype("Float64") | ||
pd_result.index = pd_result.index.astype("Float64") | ||
|
||
pd.testing.assert_frame_equal(bf_result, pd_result) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("op"), | ||
[ | ||
|
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
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
Oops, something went wrong.
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.
Throws an exception for dataframe if column_name is larger than 30?
python-bigquery-dataframes/bigframes/core/blocks.py
Line 1151 in 0e24036
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.
added limit