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

TEST-#1496: add tests for setting new column with different from fram… #2733

Merged
merged 1 commit into from
Feb 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions modin/pandas/test/dataframe/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1315,29 +1315,36 @@ def test___setitem__mask():
"data",
[
{},
pytest.param(
{"id": [], "max_speed": [], "health": []},
marks=pytest.mark.xfail(
reason="Throws an exception because generally assigning Series or other objects of length different from DataFrame does not work right now"
),
),
{"id": [], "max_speed": [], "health": []},
{"id": [1], "max_speed": [2], "health": [3]},
{"id": [4, 40, 400], "max_speed": [111, 222, 333], "health": [33, 22, 11]},
],
ids=["empty", "empty_columns"],
ids=["empty_frame", "empty_cols", "1_length_cols", "2_length_cols"],
)
@pytest.mark.parametrize(
"value",
[np.array(["one", "two"]), [11, 22]],
devin-petersohn marked this conversation as resolved.
Show resolved Hide resolved
ids=["ndarray", "list"],
[[11, 22], [11, 22, 33]],
ids=["2_length_val", "3_length_val"],
)
@pytest.mark.parametrize("convert_to_series", [False, True])
@pytest.mark.parametrize("new_col_id", [123, "new_col"], ids=["integer", "string"])
def test_setitem_on_empty_df(data, value, convert_to_series, new_col_id):
pandas_df = pandas.DataFrame(data)
modin_df = pd.DataFrame(data)

pandas_df[new_col_id] = pandas.Series(value) if convert_to_series else value
modin_df[new_col_id] = pd.Series(value) if convert_to_series else value
df_equals(modin_df, pandas_df)
def applyier(df):
if convert_to_series:
converted_value = (
pandas.Series(value)
if isinstance(df, pandas.DataFrame)
else pd.Series(value)
)
else:
converted_value = value
df[new_col_id] = converted_value
return df

eval_general(modin_df, pandas_df, applyier)


@pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
Expand Down