-
Notifications
You must be signed in to change notification settings - Fork 110
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
SNOW-1707707: Add support for Index.to_numpy #2504
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
300d2f9
SNOW-1707707: Add support for Index.to_numpy
sfc-gh-helmeleegy b57bdd5
fix tests
sfc-gh-helmeleegy e9ad46a
Merge branch 'main' into helmeleegy-SNOW-1707707
sfc-gh-helmeleegy f7eccfe
fix errors
sfc-gh-helmeleegy e60801a
fix errors
sfc-gh-helmeleegy 4f2784f
fix errors
sfc-gh-helmeleegy 2207d65
fix errors
sfc-gh-helmeleegy 547e423
fix errors
sfc-gh-helmeleegy 5b45871
Merge branch 'main' into helmeleegy-SNOW-1707707
sfc-gh-helmeleegy 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -36,31 +36,28 @@ | |
np.array([], dtype=bool), | ||
], | ||
) | ||
@sql_count_checker(query_count=1, join_count=1) | ||
def test_df_getitem_with_boolean_list_like( | ||
key, default_index_snowpark_pandas_df, default_index_native_df | ||
): | ||
# one added query to convert to native pandas and 1 added query for series initialization | ||
with SqlCounter( | ||
query_count=3 if isinstance(key, native_pd.Index) else 1, join_count=1 | ||
): | ||
# df[boolean list-like key] is the same as df.loc[:, boolean list-like key] | ||
if isinstance(key, native_pd.Index): | ||
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. There was no need to convert the native pandas index into a Snowpark pandas index when the df it's being passed to is actually a native pandas DataFrame. This was also causing test failures on the introduction of |
||
key = pd.Index(key) | ||
|
||
def get_helper(df): | ||
if isinstance(df, pd.DataFrame): | ||
return df[key] | ||
# If pandas df, adjust the length of the df and key since boolean keys need to be the same length as the axis. | ||
_key = try_convert_index_to_native(key) | ||
_df = df.iloc[: len(key)] | ||
_key = _key[: _df.shape[1]] | ||
return _df[_key] | ||
# df[boolean list-like key] is the same as df.loc[:, boolean list-like key] | ||
|
||
eval_snowpark_pandas_result( | ||
default_index_snowpark_pandas_df, | ||
default_index_native_df, | ||
get_helper, | ||
) | ||
def get_helper(df, key): | ||
if isinstance(df, pd.DataFrame): | ||
if isinstance(key, native_pd.Index): | ||
key = pd.Index(key) | ||
return df[key] | ||
# If pandas df, adjust the length of the df and key since boolean keys need to be the same length as the axis. | ||
_key = try_convert_index_to_native(key) | ||
_df = df.iloc[: len(key)] | ||
_key = _key[: _df.shape[1]] | ||
return _df[_key] | ||
|
||
eval_snowpark_pandas_result( | ||
default_index_snowpark_pandas_df, | ||
default_index_native_df, | ||
lambda df: get_helper(df, key), | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
|
This file contains 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 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.
This fixes a pre-existing issue that was causing some test failures with the introduction of
Index.to_numpy
.