-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Naren Krishna <[email protected]> Co-authored-by: Devin Petersohn <[email protected]>
- Loading branch information
1 parent
197afbf
commit c96417b
Showing
8 changed files
with
208 additions
and
15 deletions.
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved. | ||
# | ||
|
||
import modin.pandas as pd | ||
import numpy as np | ||
import pytest | ||
|
||
from tests.integ.modin.sql_counter import sql_count_checker | ||
from tests.integ.modin.utils import create_test_dfs, eval_snowpark_pandas_result | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"data, index, columns", | ||
[ | ||
([[0, 1], [2, 3]], ["cat", "dog"], ["weight", "height"]), | ||
([[0, np.nan], [np.nan, 3]], ["cat", "dog"], ["weight", "height"]), | ||
], | ||
) | ||
@pytest.mark.parametrize("dropna", [True, False]) | ||
@pytest.mark.parametrize("sort", [True, False]) | ||
@sql_count_checker(query_count=1) | ||
def test_stack(data, index, columns, dropna, sort): | ||
eval_snowpark_pandas_result( | ||
*create_test_dfs(data=data, index=index, columns=columns), | ||
lambda df: df.stack(dropna=dropna, sort=sort), | ||
) | ||
|
||
|
||
@sql_count_checker(query_count=0) | ||
def test_stack_level_unsupported(): | ||
df_single_level_cols = pd.DataFrame( | ||
[[0, 1], [2, 3]], index=["cat", "dog"], columns=["weight", "height"] | ||
) | ||
|
||
with pytest.raises( | ||
NotImplementedError, | ||
match="Snowpark pandas doesn't yet support 'level != -1' in stack API", | ||
): | ||
df_single_level_cols.stack(level=0) | ||
|
||
|
||
@sql_count_checker(query_count=0) | ||
def test_stack_multiindex_unsupported(): | ||
multicol1 = pd.MultiIndex.from_tuples([("weight", "kg"), ("weight", "pounds")]) | ||
df_multi_level_cols1 = pd.DataFrame( | ||
[[1, 2], [2, 4]], index=["cat", "dog"], columns=multicol1 | ||
) | ||
|
||
with pytest.raises( | ||
NotImplementedError, | ||
match="Snowpark pandas doesn't support multiindex columns in stack API", | ||
): | ||
df_multi_level_cols1.stack() |
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